diff --git a/app/AnimeMatrix/AniMatrix.cs b/app/AnimeMatrix/AniMatrixControl.cs similarity index 88% rename from app/AnimeMatrix/AniMatrix.cs rename to app/AnimeMatrix/AniMatrixControl.cs index a52b70f3..b7963a6f 100644 --- a/app/AnimeMatrix/AniMatrix.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -8,21 +8,26 @@ using System.Timers; namespace GHelper.AnimeMatrix { - public class AniMatrix + public class AniMatrixControl { - System.Timers.Timer matrixTimer = default!; - AnimeMatrixDevice mat; - double[] AudioValues; - WasapiCapture AudioDevice; + SettingsForm settings; + + System.Timers.Timer matrixTimer = default!; + AnimeMatrixDevice? mat; + + double[]? AudioValues; + WasapiCapture? AudioDevice; public bool IsValid => mat != null; private long lastPresent; private List maxes = new List(); - public AniMatrix() + public AniMatrixControl(SettingsForm settingsForm) { + settings = settingsForm; + try { mat = new AnimeMatrixDevice(); @@ -251,12 +256,43 @@ namespace GHelper.AnimeMatrix if (maxes.Count > 20) maxes.RemoveAt(0); maxAverage = maxes.Average(); - for (int i = 0; i < size; i++) DrawBar(20 - i, bars[i]*20/maxAverage); + for (int i = 0; i < size; i++) DrawBar(20 - i, bars[i] * 20 / maxAverage); mat.Present(); } + public void OpenMatrixPicture() + { + string fileName = null; + + Thread t = new Thread(() => + { + OpenFileDialog of = new OpenFileDialog(); + of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF"; + if (of.ShowDialog() == DialogResult.OK) + { + fileName = of.FileName; + } + return; + }); + + t.SetApartmentState(ApartmentState.STA); + t.Start(); + t.Join(); + + if (fileName is not null) + { + AppConfig.Set("matrix_picture", fileName); + AppConfig.Set("matrix_running", 2); + + SetMatrixPicture(fileName); + settings.SetMatrixRunning(2); + + } + + } + public void SetMatrixPicture(string fileName) { diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 53b03bd6..783f2628 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -1,4 +1,4 @@ -using GHelper; +using GHelper.Mode; using System.Diagnostics; using System.Management; using System.Text.Json; @@ -68,6 +68,15 @@ public static class AppConfig return _model; } + + public static string GetModelShort() + { + string model = GetModel(); + int trim = model.LastIndexOf("_"); + if (trim > 0) model = model.Substring(0, trim); + return model; + } + public static bool ContainsModel(string contains) { diff --git a/app/AsusACPI.cs b/app/AsusACPI.cs index e029452f..9c1d7aaf 100644 --- a/app/AsusACPI.cs +++ b/app/AsusACPI.cs @@ -427,6 +427,7 @@ public class AsusACPI return DeviceGet(PPT_CPUB0) >= 0 && DeviceGet(PPT_GPUC0) < 0; } + public void ScanRange() { int value; diff --git a/app/AsusUSB.cs b/app/AsusUSB.cs index 2458f3b9..a5b993ec 100644 --- a/app/AsusUSB.cs +++ b/app/AsusUSB.cs @@ -118,7 +118,7 @@ namespace GHelper _modes.Remove(3); } - if (AppConfig.ContainsModel("401")) + if (AppConfig.ContainsModel("401") || AppConfig.ContainsModel("X13")) { _modes.Remove(2); _modes.Remove(3); @@ -150,6 +150,11 @@ namespace GHelper } } + public static bool HasColor() + { + return AppConfig.ContainsModel("GA401") || AppConfig.ContainsModel("X13"); + } + public static bool HasSecondColor() { return (mode == 1 && !AppConfig.ContainsModel("TUF")); @@ -359,7 +364,7 @@ namespace GHelper if (device.ReadFeatureData(out byte[] data, AURA_HID_ID)) { device.WriteFeatureData(msg); - //device.WriteFeatureData(MESSAGE_SET); + device.WriteFeatureData(MESSAGE_SET); device.WriteFeatureData(MESSAGE_APPLY); Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg)); } diff --git a/app/AutoUpdate/AutoUpdateControl.cs b/app/AutoUpdate/AutoUpdateControl.cs new file mode 100644 index 00000000..8dba9d5d --- /dev/null +++ b/app/AutoUpdate/AutoUpdateControl.cs @@ -0,0 +1,130 @@ +using System.Diagnostics; +using System.Net; +using System.Reflection; +using System.Text.Json; + +namespace GHelper.AutoUpdate +{ + public class AutoUpdateControl + { + + SettingsForm settings; + + public string versionUrl = "http://github.com/seerge/g-helper/releases"; + static long lastUpdate; + + public AutoUpdateControl(SettingsForm settingsForm) + { + settings = settingsForm; + settings.SetVersionLabel(Properties.Strings.VersionLabel + ": " + Assembly.GetExecutingAssembly().GetName().Version); + } + + public void CheckForUpdates() + { + // Run update once per 12 hours + if (Math.Abs(DateTimeOffset.Now.ToUnixTimeSeconds() - lastUpdate) < 43200) return; + lastUpdate = DateTimeOffset.Now.ToUnixTimeSeconds(); + + Task.Run(async () => + { + await Task.Delay(TimeSpan.FromSeconds(1)); + CheckForUpdatesAsync(); + }); + } + + public void LoadReleases() + { + Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true }); + } + + async void CheckForUpdatesAsync() + { + + try + { + + using (var httpClient = new HttpClient()) + { + httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App"); + var json = await httpClient.GetStringAsync("https://api.github.com/repos/seerge/g-helper/releases/latest"); + var config = JsonSerializer.Deserialize(json); + var tag = config.GetProperty("tag_name").ToString().Replace("v", ""); + var assets = config.GetProperty("assets"); + + string url = null; + + for (int i = 0; i < assets.GetArrayLength(); i++) + { + if (assets[i].GetProperty("browser_download_url").ToString().Contains(".zip")) + url = assets[i].GetProperty("browser_download_url").ToString(); + } + + if (url is null) + url = assets[0].GetProperty("browser_download_url").ToString(); + + var gitVersion = new Version(tag); + var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); + //appVersion = new Version("0.50.0.0"); + + if (gitVersion.CompareTo(appVersion) > 0) + { + versionUrl = url; + settings.SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, true); + + if (AppConfig.GetString("skip_version") != tag) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + AutoUpdate(url); + else + AppConfig.Set("skip_version", tag); + } + + } + else + { + Logger.WriteLine($"Latest version {appVersion}"); + } + + } + } + catch (Exception ex) + { + Logger.WriteLine("Failed to check for updates:" + ex.Message); + } + + } + + + async void AutoUpdate(string requestUri) + { + + Uri uri = new Uri(requestUri); + string zipName = Path.GetFileName(uri.LocalPath); + + string exeLocation = Application.ExecutablePath; + string exeDir = Path.GetDirectoryName(exeLocation); + string zipLocation = exeDir + "\\" + zipName; + + using (WebClient client = new WebClient()) + { + client.DownloadFile(uri, zipLocation); + + Logger.WriteLine(requestUri); + Logger.WriteLine(zipLocation); + Logger.WriteLine(exeLocation); + + var cmd = new Process(); + cmd.StartInfo.UseShellExecute = false; + cmd.StartInfo.CreateNoWindow = true; + cmd.StartInfo.FileName = "powershell"; + cmd.StartInfo.Arguments = $"Start-Sleep -Seconds 1; Expand-Archive {zipLocation} -DestinationPath {exeDir} -Force; Remove-Item {zipLocation} -Force; {exeLocation}"; + cmd.Start(); + + Application.Exit(); + } + + } + + } +} diff --git a/app/Display/ScreenControl.cs b/app/Display/ScreenControl.cs new file mode 100644 index 00000000..4e2b9708 --- /dev/null +++ b/app/Display/ScreenControl.cs @@ -0,0 +1,99 @@ +using System.Diagnostics; + +namespace GHelper.Display +{ + public class ScreenControl + { + public void AutoScreen(bool force = false) + { + if (force || AppConfig.Is("screen_auto")) + { + if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online) + SetScreen(1000, 1); + else + SetScreen(60, 0); + } + else + { + SetScreen(overdrive: AppConfig.Get("overdrive")); + } + } + + public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1) + { + + if (ScreenNative.GetRefreshRate() < 0) // Laptop screen not detected or has unknown refresh rate + { + InitScreen(); + return; + } + + if (frequency >= 1000) + { + frequency = ScreenNative.GetRefreshRate(true); + } + + if (frequency > 0) + { + ScreenNative.SetRefreshRate(frequency); + } + + if (overdrive >= 0) + { + if (AppConfig.Get("no_overdrive") == 1) overdrive = 0; + Program.acpi.DeviceSet(AsusACPI.ScreenOverdrive, overdrive, "ScreenOverdrive"); + + } + + if (miniled >= 0) + { + Program.acpi.DeviceSet(AsusACPI.ScreenMiniled, miniled, "Miniled"); + Debug.WriteLine("Miniled " + miniled); + } + + InitScreen(); + } + + + public void ToogleMiniled() + { + int miniled = (AppConfig.Get("miniled") == 1) ? 0 : 1; + AppConfig.Set("miniled", miniled); + SetScreen(-1, -1, miniled); + } + + public void InitScreen() + { + int frequency = ScreenNative.GetRefreshRate(); + int maxFrequency = ScreenNative.GetRefreshRate(true); + + bool screenAuto = AppConfig.Is("screen_auto"); + bool overdriveSetting = !AppConfig.Is("no_overdrive"); + + int overdrive = Program.acpi.DeviceGet(AsusACPI.ScreenOverdrive); + int miniled = Program.acpi.DeviceGet(AsusACPI.ScreenMiniled); + + if (miniled >= 0) + AppConfig.Set("miniled", miniled); + + bool screenEnabled = (frequency >= 0); + + AppConfig.Set("frequency", frequency); + AppConfig.Set("overdrive", overdrive); + + Program.settingsForm.Invoke(delegate + { + Program.settingsForm.VisualiseScreen( + screenEnabled: screenEnabled, + screenAuto: screenAuto, + frequency: frequency, + maxFrequency: maxFrequency, + overdrive: overdrive, + overdriveSetting: overdriveSetting, + miniled: miniled + ); + }); + + } + } +} diff --git a/app/Display/ScreenInterrogatory.cs b/app/Display/ScreenInterrogatory.cs new file mode 100644 index 00000000..d16557ef --- /dev/null +++ b/app/Display/ScreenInterrogatory.cs @@ -0,0 +1,303 @@ +using System.ComponentModel; +using System.Runtime.InteropServices; + +namespace GHelper.Display +{ + public static class ScreenInterrogatory + { + public const int ERROR_SUCCESS = 0; + + #region enums + + public enum QUERY_DEVICE_CONFIG_FLAGS : uint + { + QDC_ALL_PATHS = 0x00000001, + QDC_ONLY_ACTIVE_PATHS = 0x00000002, + QDC_DATABASE_CURRENT = 0x00000004 + } + + public enum DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY : uint + { + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER = 0xFFFFFFFF, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15 = 0, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO = 2, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO = 3, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI = 4, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI = 5, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS = 6, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN = 8, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI = 9, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL = 10, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED = 11, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL = 12, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED = 13, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE = 14, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_MIRACAST = 15, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000, + DISPLAYCONFIG_OUTPUT_TECHNOLOGY_FORCE_UINT32 = 0xFFFFFFFF + } + + public enum DISPLAYCONFIG_SCANLINE_ORDERING : uint + { + DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0, + DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED, + DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3, + DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32 = 0xFFFFFFFF + } + + public enum DISPLAYCONFIG_ROTATION : uint + { + DISPLAYCONFIG_ROTATION_IDENTITY = 1, + DISPLAYCONFIG_ROTATION_ROTATE90 = 2, + DISPLAYCONFIG_ROTATION_ROTATE180 = 3, + DISPLAYCONFIG_ROTATION_ROTATE270 = 4, + DISPLAYCONFIG_ROTATION_FORCE_UINT32 = 0xFFFFFFFF + } + + public enum DISPLAYCONFIG_SCALING : uint + { + DISPLAYCONFIG_SCALING_IDENTITY = 1, + DISPLAYCONFIG_SCALING_CENTERED = 2, + DISPLAYCONFIG_SCALING_STRETCHED = 3, + DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX = 4, + DISPLAYCONFIG_SCALING_CUSTOM = 5, + DISPLAYCONFIG_SCALING_PREFERRED = 128, + DISPLAYCONFIG_SCALING_FORCE_UINT32 = 0xFFFFFFFF + } + + public enum DISPLAYCONFIG_PIXELFORMAT : uint + { + DISPLAYCONFIG_PIXELFORMAT_8BPP = 1, + DISPLAYCONFIG_PIXELFORMAT_16BPP = 2, + DISPLAYCONFIG_PIXELFORMAT_24BPP = 3, + DISPLAYCONFIG_PIXELFORMAT_32BPP = 4, + DISPLAYCONFIG_PIXELFORMAT_NONGDI = 5, + DISPLAYCONFIG_PIXELFORMAT_FORCE_UINT32 = 0xffffffff + } + + public enum DISPLAYCONFIG_MODE_INFO_TYPE : uint + { + DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, + DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, + DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF + } + + public enum DISPLAYCONFIG_DEVICE_INFO_TYPE : uint + { + DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, + DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, + DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, + DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF + } + + #endregion + + #region structs + + [StructLayout(LayoutKind.Sequential)] + public struct LUID + { + public uint LowPart; + public int HighPart; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_PATH_SOURCE_INFO + { + public LUID adapterId; + public uint id; + public uint modeInfoIdx; + public uint statusFlags; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_PATH_TARGET_INFO + { + public LUID adapterId; + public uint id; + public uint modeInfoIdx; + private DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; + private DISPLAYCONFIG_ROTATION rotation; + private DISPLAYCONFIG_SCALING scaling; + private DISPLAYCONFIG_RATIONAL refreshRate; + private DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; + public bool targetAvailable; + public uint statusFlags; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_RATIONAL + { + public uint Numerator; + public uint Denominator; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_PATH_INFO + { + public DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; + public DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; + public uint flags; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_2DREGION + { + public uint cx; + public uint cy; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO + { + public ulong pixelRate; + public DISPLAYCONFIG_RATIONAL hSyncFreq; + public DISPLAYCONFIG_RATIONAL vSyncFreq; + public DISPLAYCONFIG_2DREGION activeSize; + public DISPLAYCONFIG_2DREGION totalSize; + public uint videoStandard; + public DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_TARGET_MODE + { + public DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; + } + + [StructLayout(LayoutKind.Sequential)] + public struct POINTL + { + private int x; + private int y; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_SOURCE_MODE + { + public uint width; + public uint height; + public DISPLAYCONFIG_PIXELFORMAT pixelFormat; + public POINTL position; + } + + [StructLayout(LayoutKind.Explicit)] + public struct DISPLAYCONFIG_MODE_INFO_UNION + { + [FieldOffset(0)] + public DISPLAYCONFIG_TARGET_MODE targetMode; + + [FieldOffset(0)] + public DISPLAYCONFIG_SOURCE_MODE sourceMode; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_MODE_INFO + { + public DISPLAYCONFIG_MODE_INFO_TYPE infoType; + public uint id; + public LUID adapterId; + public DISPLAYCONFIG_MODE_INFO_UNION modeInfo; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS + { + public uint value; + } + + [StructLayout(LayoutKind.Sequential)] + public struct DISPLAYCONFIG_DEVICE_INFO_HEADER + { + public DISPLAYCONFIG_DEVICE_INFO_TYPE type; + public uint size; + public LUID adapterId; + public uint id; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct DISPLAYCONFIG_TARGET_DEVICE_NAME + { + public DISPLAYCONFIG_DEVICE_INFO_HEADER header; + public DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; + public DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; + public ushort edidManufactureId; + public ushort edidProductCodeId; + public uint connectorInstance; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] + public string monitorFriendlyDeviceName; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string monitorDevicePath; + } + + #endregion + + #region DLL-Imports + + [DllImport("user32.dll")] + public static extern int GetDisplayConfigBufferSizes( + QUERY_DEVICE_CONFIG_FLAGS flags, out uint numPathArrayElements, out uint numModeInfoArrayElements); + + [DllImport("user32.dll")] + public static extern int QueryDisplayConfig( + QUERY_DEVICE_CONFIG_FLAGS flags, + ref uint numPathArrayElements, [Out] DISPLAYCONFIG_PATH_INFO[] PathInfoArray, + ref uint numModeInfoArrayElements, [Out] DISPLAYCONFIG_MODE_INFO[] ModeInfoArray, + nint currentTopologyId + ); + + [DllImport("user32.dll")] + public static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName); + + #endregion + + private static DISPLAYCONFIG_TARGET_DEVICE_NAME DeviceName(LUID adapterId, uint targetId) + { + var deviceName = new DISPLAYCONFIG_TARGET_DEVICE_NAME + { + header = + { + size = (uint)Marshal.SizeOf(typeof (DISPLAYCONFIG_TARGET_DEVICE_NAME)), + adapterId = adapterId, + id = targetId, + type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME + } + }; + var error = DisplayConfigGetDeviceInfo(ref deviceName); + if (error != ERROR_SUCCESS) + throw new Win32Exception(error); + + return deviceName; + } + + public static IEnumerable GetAllDevices() + { + uint pathCount, modeCount; + var error = GetDisplayConfigBufferSizes(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS, out pathCount, out modeCount); + if (error != ERROR_SUCCESS) + throw new Win32Exception(error); + + var displayPaths = new DISPLAYCONFIG_PATH_INFO[pathCount]; + var displayModes = new DISPLAYCONFIG_MODE_INFO[modeCount]; + error = QueryDisplayConfig(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS, + ref pathCount, displayPaths, ref modeCount, displayModes, nint.Zero); + if (error != ERROR_SUCCESS) + throw new Win32Exception(error); + + for (var i = 0; i < modeCount; i++) + if (displayModes[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET) + yield return DeviceName(displayModes[i].adapterId, displayModes[i].id); + } + + + } + +} diff --git a/app/Display/ScreenNative.cs b/app/Display/ScreenNative.cs new file mode 100644 index 00000000..dd1d13ec --- /dev/null +++ b/app/Display/ScreenNative.cs @@ -0,0 +1,233 @@ +using System.Runtime.InteropServices; +using static GHelper.Display.ScreenInterrogatory; + +namespace GHelper.Display +{ + internal class ScreenNative + { + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public struct DEVMODE + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string dmDeviceName; + + public short dmSpecVersion; + public short dmDriverVersion; + public short dmSize; + public short dmDriverExtra; + public int dmFields; + public int dmPositionX; + public int dmPositionY; + public int dmDisplayOrientation; + public int dmDisplayFixedOutput; + public short dmColor; + public short dmDuplex; + public short dmYResolution; + public short dmTTOption; + public short dmCollate; + + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string dmFormName; + + public short dmLogPixels; + public short dmBitsPerPel; + public int dmPelsWidth; + public int dmPelsHeight; + public int dmDisplayFlags; + public int dmDisplayFrequency; + public int dmICMMethod; + public int dmICMIntent; + public int dmMediaType; + public int dmDitherType; + public int dmReserved1; + public int dmReserved2; + public int dmPanningWidth; + public int dmPanningHeight; + }; + + [Flags()] + public enum DisplaySettingsFlags : int + { + CDS_UPDATEREGISTRY = 1, + CDS_TEST = 2, + CDS_FULLSCREEN = 4, + CDS_GLOBAL = 8, + CDS_SET_PRIMARY = 0x10, + CDS_RESET = 0x40000000, + CDS_NORESET = 0x10000000 + } + + // PInvoke declaration for EnumDisplaySettings Win32 API + [DllImport("user32.dll")] + public static extern int EnumDisplaySettingsEx( + string lpszDeviceName, + int iModeNum, + ref DEVMODE lpDevMode); + + // PInvoke declaration for ChangeDisplaySettings Win32 API + [DllImport("user32.dll")] + public static extern int ChangeDisplaySettingsEx( + string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd, + DisplaySettingsFlags dwflags, IntPtr lParam); + + public static DEVMODE CreateDevmode() + { + DEVMODE dm = new DEVMODE(); + dm.dmDeviceName = new String(new char[32]); + dm.dmFormName = new String(new char[32]); + dm.dmSize = (short)Marshal.SizeOf(dm); + return dm; + } + + public enum COLORPROFILETYPE + { + CPT_ICC, + CPT_DMP, + CPT_CAMP, + CPT_GMMP + } + public enum COLORPROFILESUBTYPE + { + CPST_PERCEPTUAL, + CPST_RELATIVE_COLORIMETRIC, + CPST_SATURATION, + CPST_ABSOLUTE_COLORIMETRIC, + CPST_NONE, + CPST_RGB_WORKING_SPACE, + CPST_CUSTOM_WORKING_SPACE, + CPST_STANDARD_DISPLAY_COLOR_MODE, + CPST_EXTENDED_DISPLAY_COLOR_MODE + } + public enum WCS_PROFILE_MANAGEMENT_SCOPE + { + WCS_PROFILE_MANAGEMENT_SCOPE_SYSTEM_WIDE, + WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER + } + + [DllImport("mscms.dll", CharSet = CharSet.Unicode)] + public static extern bool WcsSetDefaultColorProfile( + WCS_PROFILE_MANAGEMENT_SCOPE scope, + string pDeviceName, + COLORPROFILETYPE cptColorProfileType, + COLORPROFILESUBTYPE cpstColorProfileSubType, + uint dwProfileID, + string pProfileName + ); + + + public const int ENUM_CURRENT_SETTINGS = -1; + public const string defaultDevice = "\\\\.\\DISPLAY1"; + + public static string? FindLaptopScreen() + { + string? laptopScreen = null; + + try + { + var devices = GetAllDevices().ToArray(); + int count = 0, displayNum = -1; + + string internalName = AppConfig.GetString("internal_display"); + + foreach (var device in devices) + { + if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || + device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || + device.monitorFriendlyDeviceName == internalName) + { + displayNum = count; + AppConfig.Set("internal_display", device.monitorFriendlyDeviceName); + } + count++; + //Logger.WriteLine(device.monitorFriendlyDeviceName + ":" + device.outputTechnology.ToString()); + } + + var screens = Screen.AllScreens; + + if (screens.Length != count) return null; + + count = 0; + foreach (var screen in screens) + { + if (count == displayNum) + { + laptopScreen = screen.DeviceName; + } + //Logger.WriteLine(screen.DeviceName); + count++; + } + + if (displayNum > 0 && count == 0) laptopScreen = defaultDevice; + } + catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); + Logger.WriteLine("Can't detect internal screen"); + laptopScreen = Screen.PrimaryScreen.DeviceName; + } + + + return laptopScreen; + } + + public static int GetRefreshRate(bool max = false) + { + DEVMODE dm = CreateDevmode(); + + string? laptopScreen = FindLaptopScreen(); + int frequency = -1; + + if (laptopScreen is null) + return -1; + + if (max) + { + int i = 0; + while (0 != EnumDisplaySettingsEx(laptopScreen, i, ref dm)) + { + if (dm.dmDisplayFrequency > frequency) frequency = dm.dmDisplayFrequency; + i++; + } + } + else + { + if (0 != EnumDisplaySettingsEx(laptopScreen, ENUM_CURRENT_SETTINGS, ref dm)) + { + frequency = dm.dmDisplayFrequency; + } + } + + + return frequency; + } + + public static int SetRefreshRate(int frequency = 120) + { + DEVMODE dm = CreateDevmode(); + string? laptopScreen = FindLaptopScreen(); + + if (laptopScreen is null) + return -1; + + if (0 != EnumDisplaySettingsEx(laptopScreen, ENUM_CURRENT_SETTINGS, ref dm)) + { + dm.dmDisplayFrequency = frequency; + int iRet = ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); + Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); + + //Fallback scenario + if (iRet != 0) + { + Thread.Sleep(300); + iRet = ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); + Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); + } + + return iRet; + } + + return 0; + + } + } +} diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index 07dc204a..a89c2948 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -1,5 +1,5 @@ -using CustomControls; -using GHelper.Properties; +using GHelper.Properties; +using GHelper.UI; namespace GHelper { diff --git a/app/Extra.cs b/app/Extra.cs index 08909292..463c151a 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -1,5 +1,8 @@ -using CustomControls; -using GHelper.Gpu; +using GHelper.Display; +using GHelper.Gpu.AMD; +using GHelper.Helpers; +using GHelper.Input; +using GHelper.UI; using System.Diagnostics; namespace GHelper @@ -7,6 +10,8 @@ namespace GHelper public partial class Extra : RForm { + ScreenControl screenControl = new ScreenControl(); + Dictionary customActions = new Dictionary { {"","--------------" }, @@ -369,7 +374,7 @@ namespace GHelper private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e) { AppConfig.Set("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0)); - Program.settingsForm.AutoScreen(true); + screenControl.AutoScreen(true); } diff --git a/app/Fans.Designer.cs b/app/Fans.Designer.cs index 512228c6..43fbbb9e 100644 --- a/app/Fans.Designer.cs +++ b/app/Fans.Designer.cs @@ -1,4 +1,4 @@ -using CustomControls; +using GHelper.UI; using System.Windows.Forms.DataVisualization.Charting; namespace GHelper @@ -31,14 +31,14 @@ namespace GHelper /// private void InitializeComponent() { - ChartArea chartArea5 = new ChartArea(); - Title title5 = new Title(); - ChartArea chartArea6 = new ChartArea(); - Title title6 = new Title(); - ChartArea chartArea7 = new ChartArea(); - Title title7 = new Title(); - ChartArea chartArea8 = new ChartArea(); - Title title8 = new Title(); + ChartArea chartArea1 = new ChartArea(); + Title title1 = new Title(); + ChartArea chartArea2 = new ChartArea(); + Title title2 = new Title(); + ChartArea chartArea3 = new ChartArea(); + Title title3 = new Title(); + ChartArea chartArea4 = new ChartArea(); + Title title4 = new Title(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Fans)); panelFans = new Panel(); labelTip = new Label(); @@ -61,13 +61,6 @@ namespace GHelper comboBoost = new RComboBox(); panelSliders = new Panel(); panelAdvanced = new Panel(); - panelTemperature = new Panel(); - labelTemp = new Label(); - labelLeftTemp = new Label(); - trackTemp = new TrackBar(); - panelTitleTemp = new Panel(); - pictureTemp = new PictureBox(); - labelTempLimit = new Label(); panelAdvancedApply = new Panel(); checkApplyUV = new RCheckBox(); buttonApplyAdvanced = new RButton(); @@ -83,6 +76,13 @@ namespace GHelper panelTitleAdvanced = new Panel(); pictureUV = new PictureBox(); labelTitleUV = new Label(); + panelTemperature = new Panel(); + labelTemp = new Label(); + labelLeftTemp = new Label(); + trackTemp = new TrackBar(); + panelTitleTemp = new Panel(); + pictureTemp = new PictureBox(); + labelTempLimit = new Label(); panelPower = new Panel(); panelApplyPower = new Panel(); checkApplyPower = new RCheckBox(); @@ -141,10 +141,6 @@ namespace GHelper panelApplyFans.SuspendLayout(); panelSliders.SuspendLayout(); panelAdvanced.SuspendLayout(); - panelTemperature.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)trackTemp).BeginInit(); - panelTitleTemp.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)pictureTemp).BeginInit(); panelAdvancedApply.SuspendLayout(); panelUViGPU.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)trackUViGPU).BeginInit(); @@ -152,6 +148,10 @@ namespace GHelper ((System.ComponentModel.ISupportInitialize)trackUV).BeginInit(); panelTitleAdvanced.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureUV).BeginInit(); + panelTemperature.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)trackTemp).BeginInit(); + panelTitleTemp.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureTemp).BeginInit(); panelPower.SuspendLayout(); panelApplyPower.SuspendLayout(); panelB0.SuspendLayout(); @@ -234,8 +234,8 @@ namespace GHelper // // chartGPU // - chartArea5.Name = "ChartArea1"; - chartGPU.ChartAreas.Add(chartArea5); + chartArea1.Name = "ChartArea1"; + chartGPU.ChartAreas.Add(chartArea1); chartGPU.Dock = DockStyle.Fill; chartGPU.Location = new Point(12, 467); chartGPU.Margin = new Padding(2, 10, 2, 10); @@ -243,13 +243,13 @@ namespace GHelper chartGPU.Size = new Size(782, 437); chartGPU.TabIndex = 17; chartGPU.Text = "chartGPU"; - title5.Name = "Title1"; - chartGPU.Titles.Add(title5); + title1.Name = "Title1"; + chartGPU.Titles.Add(title1); // // chartCPU // - chartArea6.Name = "ChartArea1"; - chartCPU.ChartAreas.Add(chartArea6); + chartArea2.Name = "ChartArea1"; + chartCPU.ChartAreas.Add(chartArea2); chartCPU.Dock = DockStyle.Fill; chartCPU.Location = new Point(12, 10); chartCPU.Margin = new Padding(2, 10, 2, 10); @@ -257,13 +257,13 @@ namespace GHelper chartCPU.Size = new Size(782, 437); chartCPU.TabIndex = 14; chartCPU.Text = "chartCPU"; - title6.Name = "Title1"; - chartCPU.Titles.Add(title6); + title2.Name = "Title1"; + chartCPU.Titles.Add(title2); // // chartXGM // - chartArea7.Name = "ChartAreaXGM"; - chartXGM.ChartAreas.Add(chartArea7); + chartArea3.Name = "ChartAreaXGM"; + chartXGM.ChartAreas.Add(chartArea3); chartXGM.Dock = DockStyle.Fill; chartXGM.Location = new Point(12, 1381); chartXGM.Margin = new Padding(2, 10, 2, 10); @@ -271,14 +271,14 @@ namespace GHelper chartXGM.Size = new Size(782, 440); chartXGM.TabIndex = 14; chartXGM.Text = "chartXGM"; - title7.Name = "Title4"; - chartXGM.Titles.Add(title7); + title3.Name = "Title4"; + chartXGM.Titles.Add(title3); chartXGM.Visible = false; // // chartMid // - chartArea8.Name = "ChartArea3"; - chartMid.ChartAreas.Add(chartArea8); + chartArea4.Name = "ChartArea3"; + chartMid.ChartAreas.Add(chartArea4); chartMid.Dock = DockStyle.Fill; chartMid.Location = new Point(12, 924); chartMid.Margin = new Padding(2, 10, 2, 10); @@ -286,8 +286,8 @@ namespace GHelper chartMid.Size = new Size(782, 437); chartMid.TabIndex = 14; chartMid.Text = "chartMid"; - title8.Name = "Title3"; - chartMid.Titles.Add(title8); + title4.Name = "Title3"; + chartMid.Titles.Add(title4); chartMid.Visible = false; // // panelTitleFans @@ -494,87 +494,6 @@ namespace GHelper panelAdvanced.TabIndex = 14; panelAdvanced.Visible = false; // - // panelTemperature - // - panelTemperature.AutoSize = true; - panelTemperature.AutoSizeMode = AutoSizeMode.GrowAndShrink; - panelTemperature.Controls.Add(labelTemp); - panelTemperature.Controls.Add(labelLeftTemp); - panelTemperature.Controls.Add(trackTemp); - panelTemperature.Dock = DockStyle.Top; - panelTemperature.Location = new Point(0, 66); - panelTemperature.Margin = new Padding(4); - panelTemperature.MaximumSize = new Size(0, 124); - panelTemperature.Name = "panelTemperature"; - panelTemperature.Size = new Size(520, 124); - panelTemperature.TabIndex = 51; - // - // labelTemp - // - labelTemp.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelTemp.Location = new Point(347, 13); - labelTemp.Margin = new Padding(4, 0, 4, 0); - labelTemp.Name = "labelTemp"; - labelTemp.Size = new Size(148, 32); - labelTemp.TabIndex = 13; - labelTemp.Text = "T"; - labelTemp.TextAlign = ContentAlignment.TopRight; - // - // labelLeftTemp - // - labelLeftTemp.AutoSize = true; - labelLeftTemp.Location = new Point(10, 10); - labelLeftTemp.Margin = new Padding(4, 0, 4, 0); - labelLeftTemp.Name = "labelLeftTemp"; - labelLeftTemp.Size = new Size(183, 32); - labelLeftTemp.TabIndex = 12; - labelLeftTemp.Text = "CPU Temp Limit"; - // - // trackTemp - // - trackTemp.Location = new Point(6, 48); - trackTemp.Margin = new Padding(4, 2, 4, 2); - trackTemp.Maximum = 0; - trackTemp.Minimum = -40; - trackTemp.Name = "trackTemp"; - trackTemp.Size = new Size(508, 90); - trackTemp.TabIndex = 11; - trackTemp.TickFrequency = 5; - trackTemp.TickStyle = TickStyle.TopLeft; - // - // panelTitleTemp - // - panelTitleTemp.Controls.Add(pictureTemp); - panelTitleTemp.Controls.Add(labelTempLimit); - panelTitleTemp.Dock = DockStyle.Top; - panelTitleTemp.Location = new Point(0, 0); - panelTitleTemp.Name = "panelTitleTemp"; - panelTitleTemp.Size = new Size(520, 66); - panelTitleTemp.TabIndex = 50; - // - // pictureTemp - // - pictureTemp.BackgroundImage = Properties.Resources.icons8_temperature_48; - pictureTemp.BackgroundImageLayout = ImageLayout.Zoom; - pictureTemp.InitialImage = null; - pictureTemp.Location = new Point(10, 18); - pictureTemp.Margin = new Padding(4, 2, 4, 10); - pictureTemp.Name = "pictureTemp"; - pictureTemp.Size = new Size(36, 38); - pictureTemp.TabIndex = 48; - pictureTemp.TabStop = false; - // - // labelTempLimit - // - labelTempLimit.AutoSize = true; - labelTempLimit.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelTempLimit.Location = new Point(51, 20); - labelTempLimit.Margin = new Padding(4, 0, 4, 0); - labelTempLimit.Name = "labelTempLimit"; - labelTempLimit.Size = new Size(140, 32); - labelTempLimit.TabIndex = 47; - labelTempLimit.Text = "Temp Limit"; - // // panelAdvancedApply // panelAdvancedApply.Controls.Add(checkApplyUV); @@ -618,11 +537,14 @@ namespace GHelper // // labelRisky // + labelRisky.BackColor = Color.IndianRed; labelRisky.Dock = DockStyle.Top; + labelRisky.ForeColor = SystemColors.ControlLightLight; labelRisky.Location = new Point(0, 504); + labelRisky.Margin = new Padding(0, 0, 0, 0); labelRisky.Name = "labelRisky"; labelRisky.Padding = new Padding(10, 10, 10, 5); - labelRisky.Size = new Size(520, 198); + labelRisky.Size = new Size(520, 220); labelRisky.TabIndex = 46; labelRisky.Text = resources.GetString("labelRisky.Text"); // @@ -755,6 +677,87 @@ namespace GHelper labelTitleUV.TabIndex = 47; labelTitleUV.Text = "Undervolting"; // + // panelTemperature + // + panelTemperature.AutoSize = true; + panelTemperature.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelTemperature.Controls.Add(labelTemp); + panelTemperature.Controls.Add(labelLeftTemp); + panelTemperature.Controls.Add(trackTemp); + panelTemperature.Dock = DockStyle.Top; + panelTemperature.Location = new Point(0, 66); + panelTemperature.Margin = new Padding(4); + panelTemperature.MaximumSize = new Size(0, 124); + panelTemperature.Name = "panelTemperature"; + panelTemperature.Size = new Size(520, 124); + panelTemperature.TabIndex = 51; + // + // labelTemp + // + labelTemp.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelTemp.Location = new Point(347, 13); + labelTemp.Margin = new Padding(4, 0, 4, 0); + labelTemp.Name = "labelTemp"; + labelTemp.Size = new Size(148, 32); + labelTemp.TabIndex = 13; + labelTemp.Text = "T"; + labelTemp.TextAlign = ContentAlignment.TopRight; + // + // labelLeftTemp + // + labelLeftTemp.AutoSize = true; + labelLeftTemp.Location = new Point(10, 10); + labelLeftTemp.Margin = new Padding(4, 0, 4, 0); + labelLeftTemp.Name = "labelLeftTemp"; + labelLeftTemp.Size = new Size(183, 32); + labelLeftTemp.TabIndex = 12; + labelLeftTemp.Text = "CPU Temp Limit"; + // + // trackTemp + // + trackTemp.Location = new Point(6, 48); + trackTemp.Margin = new Padding(4, 2, 4, 2); + trackTemp.Maximum = 0; + trackTemp.Minimum = -40; + trackTemp.Name = "trackTemp"; + trackTemp.Size = new Size(508, 90); + trackTemp.TabIndex = 11; + trackTemp.TickFrequency = 5; + trackTemp.TickStyle = TickStyle.TopLeft; + // + // panelTitleTemp + // + panelTitleTemp.Controls.Add(pictureTemp); + panelTitleTemp.Controls.Add(labelTempLimit); + panelTitleTemp.Dock = DockStyle.Top; + panelTitleTemp.Location = new Point(0, 0); + panelTitleTemp.Name = "panelTitleTemp"; + panelTitleTemp.Size = new Size(520, 66); + panelTitleTemp.TabIndex = 50; + // + // pictureTemp + // + pictureTemp.BackgroundImage = Properties.Resources.icons8_temperature_48; + pictureTemp.BackgroundImageLayout = ImageLayout.Zoom; + pictureTemp.InitialImage = null; + pictureTemp.Location = new Point(10, 18); + pictureTemp.Margin = new Padding(4, 2, 4, 10); + pictureTemp.Name = "pictureTemp"; + pictureTemp.Size = new Size(36, 38); + pictureTemp.TabIndex = 48; + pictureTemp.TabStop = false; + // + // labelTempLimit + // + labelTempLimit.AutoSize = true; + labelTempLimit.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelTempLimit.Location = new Point(51, 20); + labelTempLimit.Margin = new Padding(4, 0, 4, 0); + labelTempLimit.Name = "labelTempLimit"; + labelTempLimit.Size = new Size(140, 32); + labelTempLimit.TabIndex = 47; + labelTempLimit.Text = "Temp Limit"; + // // panelPower // panelPower.AutoSize = true; @@ -1393,12 +1396,6 @@ namespace GHelper panelSliders.PerformLayout(); panelAdvanced.ResumeLayout(false); panelAdvanced.PerformLayout(); - panelTemperature.ResumeLayout(false); - panelTemperature.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)trackTemp).EndInit(); - panelTitleTemp.ResumeLayout(false); - panelTitleTemp.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)pictureTemp).EndInit(); panelAdvancedApply.ResumeLayout(false); panelUViGPU.ResumeLayout(false); panelUViGPU.PerformLayout(); @@ -1409,6 +1406,12 @@ namespace GHelper panelTitleAdvanced.ResumeLayout(false); panelTitleAdvanced.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureUV).EndInit(); + panelTemperature.ResumeLayout(false); + panelTemperature.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)trackTemp).EndInit(); + panelTitleTemp.ResumeLayout(false); + panelTitleTemp.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureTemp).EndInit(); panelPower.ResumeLayout(false); panelPower.PerformLayout(); panelApplyPower.ResumeLayout(false); diff --git a/app/Fans.cs b/app/Fans.cs index 651f5b3b..8648c2a4 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -1,10 +1,8 @@ -using CustomControls; -using GHelper.Gpu; +using GHelper.Gpu.NVidia; +using GHelper.Mode; +using GHelper.UI; using Ryzen; -using System; using System.Diagnostics; -using System.Net.Sockets; -using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; namespace GHelper @@ -13,7 +11,7 @@ namespace GHelper { int curIndex = -1; - DataPoint curPoint = null; + DataPoint? curPoint = null; Series seriesCPU; Series seriesGPU; @@ -27,6 +25,7 @@ namespace GHelper const int fansMax = 100; NvidiaGpuControl? nvControl = null; + ModeControl modeControl = Program.modeControl; public Fans() { @@ -53,6 +52,8 @@ namespace GHelper labelGPUBoostTitle.Text = Properties.Strings.GPUBoost; labelGPUTempTitle.Text = Properties.Strings.GPUTempTarget; + labelRisky.Text = Properties.Strings.UndervoltingRisky; + InitTheme(true); MinRPM = 18; @@ -133,14 +134,14 @@ namespace GHelper labelFansResult.Visible = false; - trackUV.Minimum = Undervolter.MinCPUUV; - trackUV.Maximum = Undervolter.MaxCPUUV; + trackUV.Minimum = RyzenControl.MinCPUUV; + trackUV.Maximum = RyzenControl.MaxCPUUV; - trackUViGPU.Minimum = Undervolter.MinIGPUUV; - trackUViGPU.Maximum = Undervolter.MaxIGPUUV; + trackUViGPU.Minimum = RyzenControl.MinIGPUUV; + trackUViGPU.Maximum = RyzenControl.MaxIGPUUV; - trackTemp.Minimum = Undervolter.MinTemp; - trackTemp.Maximum = Undervolter.MaxTemp; + trackTemp.Minimum = RyzenControl.MinTemp; + trackTemp.Maximum = RyzenControl.MaxTemp; FillModes(); @@ -177,11 +178,20 @@ namespace GHelper ToggleNavigation(0); + FormClosed += Fans_FormClosed; + + } + + private void Fans_FormClosed(object? sender, FormClosedEventArgs e) + { + //Because windows charts seem to eat a lot of memory :( + GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); } private void CheckApplyUV_Click(object? sender, EventArgs e) { AppConfig.SetMode("auto_uv", checkApplyUV.Checked ? 1 : 0); + modeControl.AutoRyzen(); } public void InitAll() @@ -244,7 +254,7 @@ namespace GHelper private void ButtonApplyAdvanced_Click(object? sender, EventArgs e) { - Program.settingsForm.SetUV(true); + modeControl.SetRyzen(true); checkApplyUV.Enabled = true; } @@ -271,7 +281,7 @@ namespace GHelper labelTemp.Text = trackTemp.Value.ToString() + "°C"; - buttonAdvanced.Visible = Undervolter.IsAMD(); + buttonAdvanced.Visible = RyzenControl.IsAMD(); } @@ -332,7 +342,7 @@ namespace GHelper Modes.Remove(mode); FillModes(); - Program.settingsForm.SetPerformanceMode(AsusACPI.PerformanceBalanced); + modeControl.SetPerformanceMode(AsusACPI.PerformanceBalanced); } @@ -348,7 +358,7 @@ namespace GHelper { int mode = Modes.Add(); FillModes(); - Program.settingsForm.SetPerformanceMode(mode); + modeControl.SetPerformanceMode(mode); } public void InitMode() @@ -367,13 +377,13 @@ namespace GHelper Debug.WriteLine(selectedMode); - Program.settingsForm.SetPerformanceMode((int)selectedMode); + modeControl.SetPerformanceMode((int)selectedMode); } private void TrackGPU_MouseUp(object? sender, MouseEventArgs e) { - Program.settingsForm.SetGPUPower(); - Program.settingsForm.SetGPUClocks(true); + modeControl.SetGPUPower(); + modeControl.SetGPUClocks(true); } public void InitGPU() @@ -561,13 +571,13 @@ namespace GHelper private void TrackPower_MouseUp(object? sender, MouseEventArgs e) { - Program.settingsForm.AutoPower(); + modeControl.AutoPower(); } public void InitBoost() { - int boost = NativeMethods.GetCPUBoost(); + int boost = PowerNative.GetCPUBoost(); if (boost >= 0) comboBoost.SelectedIndex = Math.Min(boost, comboBoost.Items.Count - 1); } @@ -576,7 +586,7 @@ namespace GHelper { if (AppConfig.GetMode("auto_boost") != comboBoost.SelectedIndex) { - NativeMethods.SetCPUBoost(comboBoost.SelectedIndex); + PowerNative.SetCPUBoost(comboBoost.SelectedIndex); } AppConfig.SetMode("auto_boost", comboBoost.SelectedIndex); } @@ -587,7 +597,7 @@ namespace GHelper CheckBox chk = (CheckBox)sender; AppConfig.SetMode("auto_apply_power", chk.Checked ? 1 : 0); - Program.settingsForm.SetPerformanceMode(); + modeControl.SetPerformanceMode(); } @@ -597,7 +607,7 @@ namespace GHelper CheckBox chk = (CheckBox)sender; AppConfig.SetMode("auto_apply", chk.Checked ? 1 : 0); - Program.settingsForm.SetPerformanceMode(); + modeControl.SetPerformanceMode(); } @@ -623,13 +633,15 @@ namespace GHelper public void InitPower(bool changed = false) { - bool modeA0 = Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0; + bool modeA0 = (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0 || RyzenControl.IsAMD()); bool modeB0 = Program.acpi.IsAllAmdPPT(); bool modeC1 = Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0; panelA0.Visible = modeA0; panelB0.Visible = modeB0; + panelApplyPower.Visible = panelTitleCPU.Visible = modeA0 || modeB0 || modeC1; + // All AMD version has B0 but doesn't have C0 (Nvidia GPU) settings if (modeB0) @@ -827,10 +839,6 @@ namespace GHelper AppConfig.SetMode("auto_apply", 0); AppConfig.SetMode("auto_apply_power", 0); - Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Mode"); - - if (Program.acpi.IsXGConnected()) - AsusUSB.ResetXGM(); trackUV.Value = 0; trackUViGPU.Value = 0; @@ -839,6 +847,11 @@ namespace GHelper AdvancedScroll(); AppConfig.SetMode("cpu_temp", -1); + modeControl.ResetPerformanceMode(); + + if (Program.acpi.IsXGConnected()) AsusUSB.ResetXGM(); + + if (gpuVisible) { trackGPUCore.Value = 0; @@ -852,8 +865,8 @@ namespace GHelper AppConfig.SetMode("gpu_memory", trackGPUMemory.Value); VisualiseGPUSettings(); - Program.settingsForm.SetGPUClocks(true); - Program.settingsForm.SetGPUPower(); + modeControl.SetGPUClocks(true); + modeControl.SetGPUPower(); } } @@ -874,7 +887,7 @@ namespace GHelper if (AppConfig.Is("xgm_fan")) SaveProfile(seriesXGM, AsusFan.XGM); - Program.settingsForm.AutoFans(); + modeControl.AutoFans(); } @@ -971,8 +984,8 @@ namespace GHelper { // Get the neighboring DataPoints of the hit point - DataPoint upperPoint = null; - DataPoint lowerPoint = null; + DataPoint? upperPoint = null; + DataPoint? lowerPoint = null; if (index > 0) { diff --git a/app/GHelper.csproj b/app/GHelper.csproj index ce248f1d..323bb1c4 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ AnyCPU False True - 0.89 + 0.93 @@ -63,6 +63,7 @@ + diff --git a/app/Gpu/AmdAdl2.cs b/app/Gpu/AMD/AmdAdl2.cs similarity index 90% rename from app/Gpu/AmdAdl2.cs rename to app/Gpu/AMD/AmdAdl2.cs index 6123c891..d76504f8 100644 --- a/app/Gpu/AmdAdl2.cs +++ b/app/Gpu/AMD/AmdAdl2.cs @@ -1,8 +1,8 @@ using System.Diagnostics; using System.Runtime.InteropServices; -using static AmdAdl2.Adl2.NativeMethods; +using static GHelper.Gpu.AMD.Adl2.NativeMethods; -namespace AmdAdl2; +namespace GHelper.Gpu.AMD; #region Export Struct @@ -33,13 +33,15 @@ public struct ADLBdf } [StructLayout(LayoutKind.Sequential)] -public struct ADLSingleSensorData { +public struct ADLSingleSensorData +{ public int Supported; public int Value; } [StructLayout(LayoutKind.Sequential)] -public struct ADLPMLogDataOutput { +public struct ADLPMLogDataOutput +{ int Size; [MarshalAs(UnmanagedType.ByValArray, SizeConst = Adl2.ADL_PMLOG_MAX_SENSORS)] @@ -57,7 +59,8 @@ public struct ADLGcnInfo } [Flags] -public enum ADLAsicFamilyType { +public enum ADLAsicFamilyType +{ Undefined = 0, Discrete = 1 << 0, Integrated = 1 << 1, @@ -69,7 +72,8 @@ public enum ADLAsicFamilyType { Embedded = 1 << 7, } -public enum ADLSensorType { +public enum ADLSensorType +{ SENSOR_MAXTYPES = 0, PMLOG_CLK_GFXCLK = 1, // Current graphic clock value in MHz PMLOG_CLK_MEMCLK = 2, // Current memory clock value in MHz @@ -149,13 +153,15 @@ public enum ADLSensorType { //Throttle Status [Flags] -public enum ADL_THROTTLE_NOTIFICATION { +public enum ADL_THROTTLE_NOTIFICATION +{ ADL_PMLOG_THROTTLE_POWER = 1 << 0, ADL_PMLOG_THROTTLE_THERMAL = 1 << 1, ADL_PMLOG_THROTTLE_CURRENT = 1 << 2, }; -public enum ADL_PMLOG_SENSORS { +public enum ADL_PMLOG_SENSORS +{ ADL_SENSOR_MAXTYPES = 0, ADL_PMLOG_CLK_GFXCLK = 1, ADL_PMLOG_CLK_MEMCLK = 2, @@ -237,7 +243,8 @@ public enum ADL_PMLOG_SENSORS { /// ADLAdapterInfo Structure [StructLayout(LayoutKind.Sequential)] -public struct ADLAdapterInfo { +public struct ADLAdapterInfo +{ /// The size of the structure int Size; @@ -292,7 +299,8 @@ public struct ADLAdapterInfo { /// ADLAdapterInfo Array [StructLayout(LayoutKind.Sequential)] -public struct ADLAdapterInfoArray { +public struct ADLAdapterInfoArray +{ /// ADLAdapterInfo Array [MarshalAs(UnmanagedType.ByValArray, SizeConst = Adl2.ADL_MAX_ADAPTERS)] public ADLAdapterInfo[] ADLAdapterInfo; @@ -304,7 +312,8 @@ public struct ADLAdapterInfoArray { /// ADLDisplayID Structure [StructLayout(LayoutKind.Sequential)] -public struct ADLDisplayID { +public struct ADLDisplayID +{ /// Display Logical Index public int DisplayLogicalIndex; @@ -320,7 +329,8 @@ public struct ADLDisplayID { /// ADLDisplayInfo Structure [StructLayout(LayoutKind.Sequential)] -public struct ADLDisplayInfo { +public struct ADLDisplayInfo +{ /// Display Index public ADLDisplayID DisplayID; @@ -355,7 +365,8 @@ public struct ADLDisplayInfo { #endregion Export Struct -public class Adl2 { +public class Adl2 +{ public const string Atiadlxx_FileName = "atiadlxx.dll"; #region Internal Constant @@ -398,24 +409,30 @@ public class Adl2 { // ///// ADL Create Function to create ADL Data /// If it is 1, then ADL will only return the physical exist adapters ///// retrun ADL Error Code - public static int ADL2_Main_Control_Create(int enumConnectedAdapters, out IntPtr adlContextHandle) { + public static int ADL2_Main_Control_Create(int enumConnectedAdapters, out nint adlContextHandle) + { return NativeMethods.ADL2_Main_Control_Create(ADL_Main_Memory_Alloc_Impl_Reference, enumConnectedAdapters, out adlContextHandle); } - public static void FreeMemory(IntPtr buffer) { + public static void FreeMemory(nint buffer) + { Memory_Free_Impl(buffer); } private static bool? isDllLoaded; - public static bool Load() { + public static bool Load() + { if (isDllLoaded != null) return isDllLoaded.Value; - try { + try + { Marshal.PrelinkAll(typeof(Adl2)); isDllLoaded = true; - } catch (Exception e) when (e is DllNotFoundException or EntryPointNotFoundException) { + } + catch (Exception e) when (e is DllNotFoundException or EntryPointNotFoundException) + { Debug.WriteLine(e); isDllLoaded = false; } @@ -423,53 +440,57 @@ public class Adl2 { return isDllLoaded.Value; } - private static NativeMethods.ADL_Main_Memory_Alloc ADL_Main_Memory_Alloc_Impl_Reference = Memory_Alloc_Impl; + private static ADL_Main_Memory_Alloc ADL_Main_Memory_Alloc_Impl_Reference = Memory_Alloc_Impl; /// Build in memory allocation function /// input size /// return the memory buffer - private static IntPtr Memory_Alloc_Impl(int size) { + private static nint Memory_Alloc_Impl(int size) + { return Marshal.AllocCoTaskMem(size); } /// Build in memory free function /// input buffer - private static void Memory_Free_Impl(IntPtr buffer) { - if (IntPtr.Zero != buffer) { + private static void Memory_Free_Impl(nint buffer) + { + if (nint.Zero != buffer) + { Marshal.FreeCoTaskMem(buffer); } } - public static class NativeMethods { + public static class NativeMethods + { /// ADL Memory allocation function allows ADL to callback for memory allocation /// input size /// retrun ADL Error Code - public delegate IntPtr ADL_Main_Memory_Alloc(int size); + public delegate nint ADL_Main_Memory_Alloc(int size); // ///// ADL Create Function to create ADL Data /// Call back functin pointer which is ised to allocate memeory /// If it is 1, then ADL will only retuen the physical exist adapters ///// retrun ADL Error Code [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Main_Control_Create(ADL_Main_Memory_Alloc callback, int enumConnectedAdapters, out IntPtr adlContextHandle); + public static extern int ADL2_Main_Control_Create(ADL_Main_Memory_Alloc callback, int enumConnectedAdapters, out nint adlContextHandle); /// ADL Destroy Function to free up ADL Data /// retrun ADL Error Code [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Main_Control_Destroy(IntPtr adlContextHandle); + public static extern int ADL2_Main_Control_Destroy(nint adlContextHandle); /// ADL Function to get the number of adapters /// return number of adapters /// retrun ADL Error Code [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Adapter_NumberOfAdapters_Get(IntPtr adlContextHandle, out int numAdapters); + public static extern int ADL2_Adapter_NumberOfAdapters_Get(nint adlContextHandle, out int numAdapters); /// ADL Function to get the GPU adapter information /// return GPU adapter information /// the size of the GPU adapter struct /// retrun ADL Error Code [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Adapter_AdapterInfo_Get(IntPtr adlContextHandle, IntPtr info, int inputSize); + public static extern int ADL2_Adapter_AdapterInfo_Get(nint adlContextHandle, nint info, int inputSize); /// Function to determine if the adapter is active or not. /// The function is used to check if the adapter associated with iAdapterIndex is active @@ -477,7 +498,7 @@ public class Adl2 { /// Status of the adapter. True: Active; False: Dsiabled /// Non zero is successfull [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Adapter_Active_Get(IntPtr adlContextHandle, int adapterIndex, out int status); + public static extern int ADL2_Adapter_Active_Get(nint adlContextHandle, int adapterIndex, out int status); /// Get display information based on adapter index /// Adapter Index @@ -487,16 +508,16 @@ public class Adl2 { /// return ADL Error Code [DllImport(Atiadlxx_FileName)] public static extern int ADL2_Display_DisplayInfo_Get( - IntPtr adlContextHandle, + nint adlContextHandle, int adapterIndex, out int numDisplays, - out IntPtr displayInfoArray, + out nint displayInfoArray, int forceDetect ); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_Overdrive_Caps( - IntPtr adlContextHandle, + nint adlContextHandle, int adapterIndex, out int supported, out int enabled, @@ -504,21 +525,21 @@ public class Adl2 { ); [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_New_QueryPMLogData_Get(IntPtr adlContextHandle, int adapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput); + public static extern int ADL2_New_QueryPMLogData_Get(nint adlContextHandle, int adapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput); [DllImport(Atiadlxx_FileName)] - public static extern int ADL2_Adapter_ASICFamilyType_Get(IntPtr adlContextHandle, int adapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids); + public static extern int ADL2_Adapter_ASICFamilyType_Get(nint adlContextHandle, int adapterIndex, out ADLAsicFamilyType asicFamilyType, out int asicFamilyTypeValids); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_SwitchableGraphics_Applications_Get( - IntPtr context, + nint context, int iListType, out int lpNumApps, - out IntPtr lppAppList); + out nint lppAppList); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_Adapter_VariBright_Caps( - IntPtr context, + nint context, int iAdapterIndex, out int iSupported, out int iEnabled, @@ -526,7 +547,7 @@ public class Adl2 { [DllImport(Atiadlxx_FileName)] public static extern int ADL2_Adapter_VariBrightEnable_Set( - IntPtr context, + nint context, int iAdapterIndex, int iEnabled); @@ -553,25 +574,25 @@ public class Adl2 { [DllImport(Atiadlxx_FileName)] public static extern int ADL2_OverdriveN_SystemClocks_Get( - IntPtr context, + nint context, int adapterIndex, ref ADLODNPerformanceLevels performanceLevels); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_OverdriveN_SystemClocks_Set( - IntPtr context, + nint context, int adapterIndex, ref ADLODNPerformanceLevels performanceLevels); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_OverdriveN_MemoryClocks_Get( - IntPtr context, + nint context, int adapterIndex, ref ADLODNPerformanceLevels performanceLevels); [DllImport(Atiadlxx_FileName)] public static extern int ADL2_OverdriveN_MemoryClocks_Set( - IntPtr context, + nint context, int adapterIndex, ref ADLODNPerformanceLevels performanceLevels); } diff --git a/app/Gpu/AmdGpuControl.cs b/app/Gpu/AMD/AmdGpuControl.cs similarity index 90% rename from app/Gpu/AmdGpuControl.cs rename to app/Gpu/AMD/AmdGpuControl.cs index 72034745..2d0b1f38 100644 --- a/app/Gpu/AmdGpuControl.cs +++ b/app/Gpu/AMD/AmdGpuControl.cs @@ -1,14 +1,14 @@ -using AmdAdl2; +using GHelper.Helpers; using System.Runtime.InteropServices; -using static AmdAdl2.Adl2.NativeMethods; +using static GHelper.Gpu.AMD.Adl2.NativeMethods; -namespace GHelper.Gpu; +namespace GHelper.Gpu.AMD; // Reference: https://github.com/GPUOpen-LibrariesAndSDKs/display-library/blob/master/Sample-Managed/Program.cs public class AmdGpuControl : IGpuControl { private bool _isReady; - private IntPtr _adlContextHandle; + private nint _adlContextHandle; private readonly ADLAdapterInfo _internalDiscreteAdapter; public bool IsNvidia => false; @@ -23,7 +23,7 @@ public class AmdGpuControl : IGpuControl ADLAdapterInfoArray osAdapterInfoData = new(); int osAdapterInfoDataSize = Marshal.SizeOf(osAdapterInfoData); - IntPtr AdapterBuffer = Marshal.AllocCoTaskMem(osAdapterInfoDataSize); + nint AdapterBuffer = Marshal.AllocCoTaskMem(osAdapterInfoDataSize); Marshal.StructureToPtr(osAdapterInfoData, AdapterBuffer, false); if (ADL2_Adapter_AdapterInfo_Get(_adlContextHandle, AdapterBuffer, osAdapterInfoDataSize) != Adl2.ADL_SUCCESS) return null; @@ -76,7 +76,7 @@ public class AmdGpuControl : IGpuControl } - public bool IsValid => _isReady && _adlContextHandle != IntPtr.Zero; + public bool IsValid => _isReady && _adlContextHandle != nint.Zero; public int? GetCurrentTemperature() { @@ -112,7 +112,7 @@ public class AmdGpuControl : IGpuControl public bool SetVariBright(int enabled) { - if (_adlContextHandle == IntPtr.Zero) return false; + if (_adlContextHandle == nint.Zero) return false; ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated); if (iGPU is null) return false; @@ -125,7 +125,7 @@ public class AmdGpuControl : IGpuControl { supported = enabled = -1; - if (_adlContextHandle == IntPtr.Zero) return false; + if (_adlContextHandle == nint.Zero) return false; ADLAdapterInfo? iGPU = FindByType(ADLAsicFamilyType.Integrated); if (iGPU is null) return false; @@ -154,7 +154,7 @@ public class AmdGpuControl : IGpuControl if (!IsValid) return; - IntPtr appInfoPtr = IntPtr.Zero; + nint appInfoPtr = nint.Zero; int appCount = 0; try @@ -168,12 +168,12 @@ public class AmdGpuControl : IGpuControl // Convert the application data pointers to an array of structs var appInfoArray = new ADLSGApplicationInfo[appCount]; - IntPtr currentPtr = appInfoPtr; + nint currentPtr = appInfoPtr; for (int i = 0; i < appCount; i++) { appInfoArray[i] = Marshal.PtrToStructure(currentPtr); - currentPtr = IntPtr.Add(currentPtr, Marshal.SizeOf()); + currentPtr = nint.Add(currentPtr, Marshal.SizeOf()); } var appNames = new List(); @@ -189,7 +189,7 @@ public class AmdGpuControl : IGpuControl List immune = new() { "svchost", "system", "ntoskrnl", "csrss", "winlogon", "wininit", "smss" }; - foreach (string kill in appNames) + foreach (string kill in appNames) if (!immune.Contains(kill.ToLower())) ProcessHelper.KillByName(kill); @@ -202,7 +202,7 @@ public class AmdGpuControl : IGpuControl finally { // Clean up resources - if (appInfoPtr != IntPtr.Zero) + if (appInfoPtr != nint.Zero) { Marshal.FreeCoTaskMem(appInfoPtr); } @@ -213,10 +213,10 @@ public class AmdGpuControl : IGpuControl private void ReleaseUnmanagedResources() { - if (_adlContextHandle != IntPtr.Zero) + if (_adlContextHandle != nint.Zero) { ADL2_Main_Control_Destroy(_adlContextHandle); - _adlContextHandle = IntPtr.Zero; + _adlContextHandle = nint.Zero; _isReady = false; } } diff --git a/app/Gpu/GPUModeControl.cs b/app/Gpu/GPUModeControl.cs new file mode 100644 index 00000000..e1cd8a74 --- /dev/null +++ b/app/Gpu/GPUModeControl.cs @@ -0,0 +1,322 @@ +using GHelper.Display; +using GHelper.Gpu.NVidia; +using GHelper.Helpers; +using System.Diagnostics; + +namespace GHelper.Gpu +{ + public class GPUModeControl + { + SettingsForm settings; + ScreenControl screenControl = new ScreenControl(); + + public GPUModeControl(SettingsForm settingsForm) + { + settings = settingsForm; + } + + public void InitGPUMode() + { + int eco = Program.acpi.DeviceGet(AsusACPI.GPUEco); + int mux = Program.acpi.DeviceGet(AsusACPI.GPUMux); + + Logger.WriteLine("Eco flag : " + eco); + Logger.WriteLine("Mux flag : " + mux); + + int GpuMode; + + if (mux == 0) + { + GpuMode = AsusACPI.GPUModeUltimate; + } + else + { + if (eco == 1) + GpuMode = AsusACPI.GPUModeEco; + else + GpuMode = AsusACPI.GPUModeStandard; + + // Ultimate mode not suported + if (mux != 1) settings.HideUltimateMode(); + // GPU mode not supported + if (eco < 0 && mux < 0) settings.HideGPUModes(); + } + + AppConfig.Set("gpu_mode", GpuMode); + + InitXGM(); + settings.VisualiseGPUMode(GpuMode); + } + + + public void SetGPUMode(int GPUMode) + { + + int CurrentGPU = AppConfig.Get("gpu_mode"); + AppConfig.Set("gpu_auto", 0); + + if (CurrentGPU == GPUMode) + { + settings.VisualiseGPUMode(); + return; + } + + var restart = false; + var changed = false; + + if (CurrentGPU == AsusACPI.GPUModeUltimate) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertUltimateOff, Properties.Strings.AlertUltimateTitle, MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + Program.acpi.DeviceSet(AsusACPI.GPUMux, 1, "GPUMux"); + restart = true; + changed = true; + } + } + else if (GPUMode == AsusACPI.GPUModeUltimate) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertUltimateOn, Properties.Strings.AlertUltimateTitle, MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + Program.acpi.DeviceSet(AsusACPI.GPUMux, 0, "GPUMux"); + restart = true; + changed = true; + } + + } + else if (GPUMode == AsusACPI.GPUModeEco) + { + settings.VisualiseGPUMode(GPUMode); + SetGPUEco(1, true); + changed = true; + } + else if (GPUMode == AsusACPI.GPUModeStandard) + { + settings.VisualiseGPUMode(GPUMode); + SetGPUEco(0); + changed = true; + } + + if (changed) + { + AppConfig.Set("gpu_mode", GPUMode); + } + + if (restart) + { + settings.VisualiseGPUMode(); + Process.Start("shutdown", "/r /t 1"); + } + + } + + + + public void SetGPUEco(int eco, bool hardWay = false) + { + + settings.LockGPUModes(); + + Task.Run(async () => + { + + int status = 1; + + if (eco == 1) + { + if (NvidiaSmi.GetDisplayActiveStatus()) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.EnableOptimusText, Properties.Strings.EnableOptimusTitle, MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.No) + { + InitGPUMode(); + return; + } + } + + HardwareControl.KillGPUApps(); + } + + Logger.WriteLine($"Running eco command {eco}"); + + status = Program.acpi.SetGPUEco(eco); + + if (status == 0 && eco == 1 && hardWay) RestartGPU(); + + await Task.Delay(TimeSpan.FromMilliseconds(100)); + + settings.Invoke(delegate + { + InitGPUMode(); + screenControl.AutoScreen(); + }); + + if (eco == 0) + { + await Task.Delay(TimeSpan.FromMilliseconds(3000)); + HardwareControl.RecreateGpuControl(); + Program.modeControl.SetGPUClocks(false); + } + + }); + + + } + + public static bool IsPlugged() + { + bool optimizedUSBC = AppConfig.Get("optimized_usbc") != 1; + + return SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online && + (optimizedUSBC || Program.acpi.DeviceGet(AsusACPI.ChargerMode) < AsusACPI.ChargerUSB); + + } + + public bool AutoGPUMode() + { + + bool GpuAuto = AppConfig.Is("gpu_auto"); + bool ForceGPU = AppConfig.ContainsModel("503"); + + int GpuMode = AppConfig.Get("gpu_mode"); + + if (!GpuAuto && !ForceGPU) return false; + + int eco = Program.acpi.DeviceGet(AsusACPI.GPUEco); + int mux = Program.acpi.DeviceGet(AsusACPI.GPUMux); + + if (mux == 0) // GPU in Ultimate, ignore + return false; + else + { + + if (ReEnableGPU()) return true; + + if (eco == 1) + if ((GpuAuto && IsPlugged()) || (ForceGPU && GpuMode == AsusACPI.GPUModeStandard)) + { + SetGPUEco(0); + return true; + } + if (eco == 0) + if ((GpuAuto && !IsPlugged()) || (ForceGPU && GpuMode == AsusACPI.GPUModeEco)) + { + + if (HardwareControl.IsUsedGPU()) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertDGPU, Properties.Strings.AlertDGPUTitle, MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.No) return false; + } + + SetGPUEco(1); + return true; + } + } + + return false; + + } + + + public void RestartGPU(bool confirm = true) + { + if (HardwareControl.GpuControl is null) return; + if (!HardwareControl.GpuControl!.IsNvidia) return; + + if (confirm) + { + DialogResult dialogResult = MessageBox.Show(Properties.Strings.RestartGPU, Properties.Strings.EcoMode, MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.No) return; + } + + ProcessHelper.RunAsAdmin("gpurestart"); + + if (!ProcessHelper.IsUserAdministrator()) return; + + Logger.WriteLine("Trying to restart dGPU"); + + Task.Run(async () => + { + settings.LockGPUModes("Restarting GPU ..."); + + var nvControl = (NvidiaGpuControl)HardwareControl.GpuControl; + bool status = nvControl.RestartGPU(); + + settings.Invoke(delegate + { + //labelTipGPU.Text = status ? "GPU Restarted, you can try Eco mode again" : "Failed to restart GPU"; TODO + InitGPUMode(); + }); + }); + + } + + + public bool ReEnableGPU() + { + + if (AppConfig.Get("gpu_reenable") != 1) return false; + if (Screen.AllScreens.Length <= 1) return false; + + Logger.WriteLine("Re-enabling gpu for 503 model"); + + Thread.Sleep(1000); + SetGPUEco(1); + Thread.Sleep(1000); + SetGPUEco(0); + return true; + } + + public void InitXGM() + { + bool connected = Program.acpi.IsXGConnected(); + int activated = Program.acpi.DeviceGet(AsusACPI.GPUXG); + settings.VisualizeXGM(connected, activated == 1); + } + + public void ToggleXGM() + { + + Task.Run(async () => + { + settings.LockGPUModes(); + + if (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1) + { + HardwareControl.KillGPUApps(); + DialogResult dialogResult = MessageBox.Show("Did you close all applications running on XG Mobile?", "Disabling XG Mobile", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM"); + await Task.Delay(TimeSpan.FromSeconds(15)); + } + } + else + { + Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM"); + AsusUSB.ApplyXGMLight(AppConfig.Is("xmg_light")); + + await Task.Delay(TimeSpan.FromSeconds(15)); + + if (AppConfig.IsMode("auto_apply")) + AsusUSB.SetXGMFan(AppConfig.GetFanConfig(AsusFan.XGM)); + } + + settings.Invoke(delegate + { + InitGPUMode(); + }); + }); + } + + public void KillGPUApps() + { + if (HardwareControl.GpuControl is not null) + { + HardwareControl.GpuControl.KillGPUApps(); + } + } + + } +} diff --git a/app/Gpu/NvidiaGpuControl.cs b/app/Gpu/NVidia/NvidiaGpuControl.cs similarity index 89% rename from app/Gpu/NvidiaGpuControl.cs rename to app/Gpu/NVidia/NvidiaGpuControl.cs index 53c9b220..a3bee55b 100644 --- a/app/Gpu/NvidiaGpuControl.cs +++ b/app/Gpu/NVidia/NvidiaGpuControl.cs @@ -1,4 +1,5 @@ -using NvAPIWrapper.GPU; +using GHelper.Helpers; +using NvAPIWrapper.GPU; using NvAPIWrapper.Native; using NvAPIWrapper.Native.GPU; using NvAPIWrapper.Native.GPU.Structures; @@ -6,7 +7,7 @@ using NvAPIWrapper.Native.Interfaces.GPU; using System.Diagnostics; using static NvAPIWrapper.Native.GPU.Structures.PerformanceStates20InfoV1; -namespace GHelper.Gpu; +namespace GHelper.Gpu.NVidia; public class NvidiaGpuControl : IGpuControl { @@ -55,7 +56,16 @@ public class NvidiaGpuControl : IGpuControl try { Process[] processes = internalGpu.GetActiveApplications(); - foreach (Process process in processes) ProcessHelper.KillByProcess(process); + foreach (Process process in processes) + try + { + Logger.WriteLine("Kill:" + process.ProcessName); + ProcessHelper.KillByProcess(process); + } + catch (Exception ex) + { + Logger.WriteLine(ex.Message); + } } catch (Exception ex) { @@ -117,8 +127,8 @@ public class NvidiaGpuControl : IGpuControl public int SetClocksFromConfig() { - int core = AppConfig.Get("gpu_core",0); - int memory = AppConfig.Get("gpu_memory",0); + int core = AppConfig.Get("gpu_core", 0); + int memory = AppConfig.Get("gpu_memory", 0); int status = SetClocks(core, memory); return status; } @@ -136,7 +146,7 @@ public class NvidiaGpuControl : IGpuControl var voltageEntry = new PerformanceStates20BaseVoltageEntryV1(PerformanceVoltageDomain.Core, new PerformanceStates20ParameterDelta(voltage)); PerformanceStates20ClockEntryV1[] clocks = { coreClock, memoryClock }; - PerformanceStates20BaseVoltageEntryV1[] voltages = { }; + PerformanceStates20BaseVoltageEntryV1[] voltages = { }; PerformanceState20[] performanceStates = { new PerformanceState20(PerformanceStateId.P0_3DPerformance, clocks, voltages) }; diff --git a/app/Gpu/NVidia/NvidiaSmi.cs b/app/Gpu/NVidia/NvidiaSmi.cs new file mode 100644 index 00000000..c3ff47fa --- /dev/null +++ b/app/Gpu/NVidia/NvidiaSmi.cs @@ -0,0 +1,65 @@ +using Ryzen; +using System.Diagnostics; +using System.Text.RegularExpressions; + +public static class NvidiaSmi +{ + public static bool GetDisplayActiveStatus() + { + // Non AMD devices doesn't seem to be affected + if (!RyzenControl.IsAMD()) return false; + + string commandOutput = RunNvidiaSmiCommand(); + + Logger.WriteLine(commandOutput); + + if (commandOutput.Length == 0) return false; + if (!commandOutput.Contains("RTX 40")) return false; + + // Extract the "Display Active" status using regular expressions + string displayActivePattern = @"Display Active\s+:\s+(\w+)"; + + Match match = Regex.Match(commandOutput, displayActivePattern, RegexOptions.IgnoreCase); + + if (match.Success) + { + string status = match.Groups[1].Value.ToLower().Trim(' '); + return status == "enabled"; + } + + return false; // Return false if the "Display Active" status is not found + } + + private static string RunNvidiaSmiCommand(string arguments = "-i 0 -q") + { + ProcessStartInfo startInfo = new ProcessStartInfo + { + FileName = "nvidia-smi", + Arguments = arguments, + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + Process process = new Process + { + StartInfo = startInfo + }; + + try + { + process.Start(); + string output = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + return output; + } + catch (Exception ex) + { + //return File.ReadAllText(@"smi.txt"); + Debug.WriteLine(ex.Message); + } + + return ""; + + } +} diff --git a/app/HardwareControl.cs b/app/HardwareControl.cs index ec76f837..afe96dfe 100644 --- a/app/HardwareControl.cs +++ b/app/HardwareControl.cs @@ -1,5 +1,9 @@ using GHelper; using GHelper.Gpu; +using GHelper.Gpu.NVidia; +using GHelper.Gpu.AMD; + +using GHelper.Helpers; using System.Diagnostics; public static class HardwareControl @@ -20,7 +24,7 @@ public static class HardwareControl { int max = 58; int configMax = AppConfig.Get("fan_max"); - if (configMax > 100) configMax = 0; // skipping inadvequate settings + if (configMax > 80) configMax = 0; // skipping inadvequate settings if (AppConfig.ContainsModel("401")) max = 72; else if (AppConfig.ContainsModel("503")) max = 68; @@ -41,7 +45,7 @@ public static class HardwareControl } int fanMax = GetFanMax(); - if (fan > fanMax && fan < 110) SetFanMax(fan); + if (fan > fanMax && fan < 80) SetFanMax(fan); if (AppConfig.Is("fan_rpm")) return GHelper.Properties.Strings.FanSpeed + (fan * 100).ToString() + "RPM"; @@ -188,14 +192,6 @@ public static class HardwareControl { List tokill = new() { "EADesktop", "RadeonSoftware", "epicgameslauncher", "ASUSSmartDisplayControl" }; - - if (AppConfig.Is("kill_gpu_apps")) - { - tokill.Add("nvdisplay.container"); - tokill.Add("nvcontainer"); - tokill.Add("nvcplui"); - } - foreach (string kill in tokill) ProcessHelper.KillByName(kill); if (AppConfig.Is("kill_gpu_apps") && GpuControl is not null) diff --git a/app/Logger.cs b/app/Helpers/Logger.cs similarity index 100% rename from app/Logger.cs rename to app/Helpers/Logger.cs diff --git a/app/OSDBase.cs b/app/Helpers/OSDBase.cs similarity index 59% rename from app/OSDBase.cs rename to app/Helpers/OSDBase.cs index 45f99142..92b6a5dd 100644 --- a/app/OSDBase.cs +++ b/app/Helpers/OSDBase.cs @@ -1,7 +1,7 @@ using System.Drawing.Imaging; using System.Runtime.InteropServices; -namespace OSD +namespace GHelper.Helpers { public class OSDNativeForm : NativeWindow, IDisposable @@ -19,11 +19,11 @@ namespace OSD protected internal void Invalidate() { - this.UpdateLayeredWindow(); + UpdateLayeredWindow(); } private void UpdateLayeredWindow() { - Bitmap bitmap1 = new Bitmap(this.Size.Width, this.Size.Height, PixelFormat.Format32bppArgb); + Bitmap bitmap1 = new Bitmap(Size.Width, Size.Height, PixelFormat.Format32bppArgb); using (Graphics graphics1 = Graphics.FromImage(bitmap1)) { Rectangle rectangle1; @@ -31,27 +31,27 @@ namespace OSD POINT point1; POINT point2; BLENDFUNCTION blendfunction1; - rectangle1 = new Rectangle(0, 0, this.Size.Width, this.Size.Height); + rectangle1 = new Rectangle(0, 0, Size.Width, Size.Height); PerformPaint(new PaintEventArgs(graphics1, rectangle1)); - IntPtr ptr1 = User32.GetDC(IntPtr.Zero); - IntPtr ptr2 = Gdi32.CreateCompatibleDC(ptr1); - IntPtr ptr3 = bitmap1.GetHbitmap(Color.FromArgb(0)); - IntPtr ptr4 = Gdi32.SelectObject(ptr2, ptr3); - size1.cx = this.Size.Width; - size1.cy = this.Size.Height; - point1.x = this.Location.X; - point1.x = this.Location.X; - point1.y = this.Location.Y; + nint ptr1 = User32.GetDC(nint.Zero); + nint ptr2 = Gdi32.CreateCompatibleDC(ptr1); + nint ptr3 = bitmap1.GetHbitmap(Color.FromArgb(0)); + nint ptr4 = Gdi32.SelectObject(ptr2, ptr3); + size1.cx = Size.Width; + size1.cy = Size.Height; + point1.x = Location.X; + point1.x = Location.X; + point1.y = Location.Y; point2.x = 0; point2.y = 0; blendfunction1 = new BLENDFUNCTION(); blendfunction1.BlendOp = 0; blendfunction1.BlendFlags = 0; - blendfunction1.SourceConstantAlpha = this._alpha; + blendfunction1.SourceConstantAlpha = _alpha; blendfunction1.AlphaFormat = 1; - User32.UpdateLayeredWindow(base.Handle, ptr1, ref point1, ref size1, ptr2, ref point2, 0, ref blendfunction1, 2); //2=ULW_ALPHA + User32.UpdateLayeredWindow(Handle, ptr1, ref point1, ref size1, ptr2, ref point2, 0, ref blendfunction1, 2); //2=ULW_ALPHA Gdi32.SelectObject(ptr2, ptr4); - User32.ReleaseDC(IntPtr.Zero, ptr1); + User32.ReleaseDC(nint.Zero, ptr1); Gdi32.DeleteObject(ptr3); Gdi32.DeleteDC(ptr2); } @@ -59,25 +59,25 @@ namespace OSD public virtual void Show() { - if (base.Handle == IntPtr.Zero) //if handle don't equal to zero - window was created and just hided - this.CreateWindowOnly(); - User32.ShowWindow(base.Handle, User32.SW_SHOWNOACTIVATE); + if (Handle == nint.Zero) //if handle don't equal to zero - window was created and just hided + CreateWindowOnly(); + User32.ShowWindow(Handle, User32.SW_SHOWNOACTIVATE); } public virtual void Hide() { - if (base.Handle == IntPtr.Zero) + if (Handle == nint.Zero) return; - User32.ShowWindow(base.Handle, User32.SW_HIDE); - this.DestroyHandle(); + User32.ShowWindow(Handle, User32.SW_HIDE); + DestroyHandle(); } public virtual void Close() { - this.Hide(); - this.Dispose(); + Hide(); + Dispose(); } private void CreateWindowOnly() @@ -85,55 +85,55 @@ namespace OSD CreateParams params1 = new CreateParams(); params1.Caption = "FloatingNativeWindow"; - int nX = this._location.X; - int nY = this._location.Y; - Screen screen1 = Screen.FromHandle(base.Handle); - if ((nX + this._size.Width) > screen1.Bounds.Width) + int nX = _location.X; + int nY = _location.Y; + Screen screen1 = Screen.FromHandle(Handle); + if (nX + _size.Width > screen1.Bounds.Width) { - nX = screen1.Bounds.Width - this._size.Width; + nX = screen1.Bounds.Width - _size.Width; } - if ((nY + this._size.Height) > screen1.Bounds.Height) + if (nY + _size.Height > screen1.Bounds.Height) { - nY = screen1.Bounds.Height - this._size.Height; + nY = screen1.Bounds.Height - _size.Height; } - this._location = new Point(nX, nY); - Size size1 = this._size; - Point point1 = this._location; + _location = new Point(nX, nY); + Size size1 = _size; + Point point1 = _location; params1.X = nX; params1.Y = nY; params1.Height = size1.Height; params1.Width = size1.Width; - params1.Parent = IntPtr.Zero; + params1.Parent = nint.Zero; uint ui = User32.WS_POPUP; params1.Style = (int)ui; params1.ExStyle = User32.WS_EX_TOPMOST | User32.WS_EX_TOOLWINDOW | User32.WS_EX_LAYERED | User32.WS_EX_NOACTIVATE | User32.WS_EX_TRANSPARENT; - this.CreateHandle(params1); - this.UpdateLayeredWindow(); + CreateHandle(params1); + UpdateLayeredWindow(); } protected virtual void SetBoundsCore(int x, int y, int width, int height) { - if (((this.X != x) || (this.Y != y)) || ((this.Width != width) || (this.Height != height))) + if (X != x || Y != y || Width != width || Height != height) { - if (base.Handle != IntPtr.Zero) + if (Handle != nint.Zero) { int num1 = 20; - if ((this.X == x) && (this.Y == y)) + if (X == x && Y == y) { num1 |= 2; } - if ((this.Width == width) && (this.Height == height)) + if (Width == width && Height == height) { num1 |= 1; } - User32.SetWindowPos(base.Handle, IntPtr.Zero, x, y, width, height, (uint)num1); + User32.SetWindowPos(Handle, nint.Zero, x, y, width, height, (uint)num1); } else { - this.Location = new Point(x, y); - this.Size = new Size(width, height); + Location = new Point(x, y); + Size = new Size(width, height); } } } @@ -147,20 +147,20 @@ namespace OSD /// public virtual Point Location { - get { return this._location; } + get { return _location; } set { - if (base.Handle != IntPtr.Zero) + if (Handle != nint.Zero) { - this.SetBoundsCore(value.X, value.Y, this._size.Width, this._size.Height); + SetBoundsCore(value.X, value.Y, _size.Width, _size.Height); RECT rect = new RECT(); - User32.GetWindowRect(base.Handle, ref rect); - this._location = new Point(rect.left, rect.top); - this.UpdateLayeredWindow(); + User32.GetWindowRect(Handle, ref rect); + _location = new Point(rect.left, rect.top); + UpdateLayeredWindow(); } else { - this._location = value; + _location = value; } } } @@ -169,20 +169,20 @@ namespace OSD /// public virtual Size Size { - get { return this._size; } + get { return _size; } set { - if (base.Handle != IntPtr.Zero) + if (Handle != nint.Zero) { - this.SetBoundsCore(this._location.X, this._location.Y, value.Width, value.Height); + SetBoundsCore(_location.X, _location.Y, value.Width, value.Height); RECT rect = new RECT(); - User32.GetWindowRect(base.Handle, ref rect); - this._size = new Size(rect.right - rect.left, rect.bottom - rect.top); - this.UpdateLayeredWindow(); + User32.GetWindowRect(Handle, ref rect); + _size = new Size(rect.right - rect.left, rect.bottom - rect.top); + UpdateLayeredWindow(); } else { - this._size = value; + _size = value; } } } @@ -191,10 +191,10 @@ namespace OSD /// public int Height { - get { return this._size.Height; } + get { return _size.Height; } set { - this._size = new Size(this._size.Width, value); + _size = new Size(_size.Width, value); } } /// @@ -202,10 +202,10 @@ namespace OSD /// public int Width { - get { return this._size.Width; } + get { return _size.Width; } set { - this._size = new Size(value, this._size.Height); + _size = new Size(value, _size.Height); } } /// @@ -213,10 +213,10 @@ namespace OSD /// public int X { - get { return this._location.X; } + get { return _location.X; } set { - this.Location = new Point(value, this.Location.Y); + Location = new Point(value, Location.Y); } } /// @@ -224,10 +224,10 @@ namespace OSD /// public int Y { - get { return this._location.Y; } + get { return _location.Y; } set { - this.Location = new Point(this.Location.X, value); + Location = new Point(Location.X, value); } } /// @@ -237,7 +237,7 @@ namespace OSD { get { - return new Rectangle(new Point(0, 0), this._size); + return new Rectangle(new Point(0, 0), _size); } } /// @@ -245,12 +245,12 @@ namespace OSD /// public byte Alpha { - get { return this._alpha; } + get { return _alpha; } set { - if (this._alpha == value) return; - this._alpha = value; - this.UpdateLayeredWindow(); + if (_alpha == value) return; + _alpha = value; + UpdateLayeredWindow(); } } #endregion @@ -258,15 +258,15 @@ namespace OSD #region IDisposable Members public void Dispose() { - this.Dispose(true); + Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { - this.DestroyHandle(); - this._disposed = true; + DestroyHandle(); + _disposed = true; } } #endregion @@ -299,16 +299,16 @@ namespace OSD { public uint cbSize; public uint dwFlags; - public IntPtr hWnd; + public nint hWnd; public uint dwHoverTime; } [StructLayout(LayoutKind.Sequential)] internal struct MSG { - public IntPtr hwnd; + public nint hwnd; public int message; - public IntPtr wParam; - public IntPtr lParam; + public nint wParam; + public nint lParam; public int time; public int pt_x; public int pt_y; @@ -345,69 +345,69 @@ namespace OSD { } [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool AnimateWindow(IntPtr hWnd, uint dwTime, uint dwFlags); + internal static extern bool AnimateWindow(nint hWnd, uint dwTime, uint dwFlags); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool ClientToScreen(IntPtr hWnd, ref POINT pt); + internal static extern bool ClientToScreen(nint hWnd, ref POINT pt); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool DispatchMessage(ref MSG msg); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool DrawFocusRect(IntPtr hWnd, ref RECT rect); + internal static extern bool DrawFocusRect(nint hWnd, ref RECT rect); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr GetDC(IntPtr hWnd); + internal static extern nint GetDC(nint hWnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr GetFocus(); + internal static extern nint GetFocus(); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern ushort GetKeyState(int virtKey); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool GetMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr GetParent(IntPtr hWnd); + internal static extern nint GetParent(nint hWnd); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern bool GetClientRect(IntPtr hWnd, [In, Out] ref RECT rect); + public static extern bool GetClientRect(nint hWnd, [In, Out] ref RECT rect); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern int GetWindowLong(IntPtr hWnd, int nIndex); + internal static extern int GetWindowLong(nint hWnd, int nIndex); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr GetWindow(IntPtr hWnd, int cmd); + internal static extern nint GetWindow(nint hWnd, int cmd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect); + internal static extern bool GetWindowRect(nint hWnd, ref RECT rect); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool HideCaret(IntPtr hWnd); + internal static extern bool HideCaret(nint hWnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool InvalidateRect(IntPtr hWnd, ref RECT rect, bool erase); + internal static extern bool InvalidateRect(nint hWnd, ref RECT rect, bool erase); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr LoadCursor(IntPtr hInstance, uint cursor); + internal static extern nint LoadCursor(nint hInstance, uint cursor); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, [In, Out] ref RECT rect, int cPoints); + public static extern int MapWindowPoints(nint hWndFrom, nint hWndTo, [In, Out] ref RECT rect, int cPoints); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool MoveWindow(IntPtr hWnd, int x, int y, int width, int height, bool repaint); + internal static extern bool MoveWindow(nint hWnd, int x, int y, int width, int height, bool repaint); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool PeekMessage(ref MSG msg, int hWnd, uint wFilterMin, uint wFilterMax, uint wFlag); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam); + internal static extern bool PostMessage(nint hWnd, int Msg, uint wParam, uint lParam); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool ReleaseCapture(); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + internal static extern int ReleaseDC(nint hWnd, nint hDC); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool ScreenToClient(IntPtr hWnd, ref POINT pt); + internal static extern bool ScreenToClient(nint hWnd, ref POINT pt); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern uint SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam); + internal static extern uint SendMessage(nint hWnd, int Msg, uint wParam, uint lParam); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr SetCursor(IntPtr hCursor); + internal static extern nint SetCursor(nint hCursor); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr SetFocus(IntPtr hWnd); + internal static extern nint SetFocus(nint hWnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int newLong); + internal static extern int SetWindowLong(nint hWnd, int nIndex, int newLong); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int X, int Y, int Width, int Height, uint flags); + internal static extern int SetWindowPos(nint hWnd, nint hWndAfter, int X, int Y, int Width, int Height, uint flags); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool redraw); + internal static extern bool SetWindowRgn(nint hWnd, nint hRgn, bool redraw); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool ShowCaret(IntPtr hWnd); + internal static extern bool ShowCaret(nint hWnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool SetCapture(IntPtr hWnd); + internal static extern bool SetCapture(nint hWnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern int ShowWindow(IntPtr hWnd, short cmdShow); + internal static extern int ShowWindow(nint hWnd, short cmdShow); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int bRetValue, uint fWinINI); [DllImport("User32.dll", CharSet = CharSet.Auto)] @@ -415,9 +415,9 @@ namespace OSD [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool TranslateMessage(ref MSG msg); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref POINT pptDst, ref SIZE psize, IntPtr hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags); + internal static extern bool UpdateLayeredWindow(nint hwnd, nint hdcDst, ref POINT pptDst, ref SIZE psize, nint hdcSrc, ref POINT pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags); [DllImport("User32.dll", CharSet = CharSet.Auto)] - internal static extern bool UpdateWindow(IntPtr hwnd); + internal static extern bool UpdateWindow(nint hwnd); [DllImport("User32.dll", CharSet = CharSet.Auto)] internal static extern bool WaitMessage(); [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] @@ -431,25 +431,25 @@ namespace OSD { } [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern int CombineRgn(IntPtr dest, IntPtr src1, IntPtr src2, int flags); + internal static extern int CombineRgn(nint dest, nint src1, nint src2, int flags); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush); + internal static extern nint CreateBrushIndirect(ref LOGBRUSH brush); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr CreateCompatibleDC(IntPtr hDC); + internal static extern nint CreateCompatibleDC(nint hDC); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr CreateRectRgnIndirect(ref RECT rect); + internal static extern nint CreateRectRgnIndirect(ref RECT rect); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern bool DeleteDC(IntPtr hDC); + internal static extern bool DeleteDC(nint hDC); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr DeleteObject(IntPtr hObject); + internal static extern nint DeleteObject(nint hObject); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern int GetClipBox(IntPtr hDC, ref RECT rectBox); + internal static extern int GetClipBox(nint hDC, ref RECT rectBox); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern bool PatBlt(IntPtr hDC, int x, int y, int width, int height, uint flags); + internal static extern bool PatBlt(nint hDC, int x, int y, int width, int height, uint flags); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern int SelectClipRgn(IntPtr hDC, IntPtr hRgn); + internal static extern int SelectClipRgn(nint hDC, nint hRgn); [DllImport("gdi32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); + internal static extern nint SelectObject(nint hDC, nint hObject); } [StructLayout(LayoutKind.Sequential)] public struct LOGBRUSH diff --git a/app/OptimizationService.cs b/app/Helpers/OptimizationService.cs similarity index 94% rename from app/OptimizationService.cs rename to app/Helpers/OptimizationService.cs index 3d5b1eec..e27cb1d6 100644 --- a/app/OptimizationService.cs +++ b/app/Helpers/OptimizationService.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; -namespace GHelper +namespace GHelper.Helpers { public static class OptimizationService { @@ -52,7 +52,7 @@ namespace GHelper public static bool IsRunning() { - return (Process.GetProcessesByName("AsusOptimization").Count() > 0); + return Process.GetProcessesByName("AsusOptimization").Count() > 0; } public static int GetRunningCount() @@ -66,7 +66,7 @@ namespace GHelper } - public static void SetBacklightOffDelay(int value = 60) + public static void SetBacklightOffDelay(int value = 60) { try { diff --git a/app/ProcessHelper.cs b/app/Helpers/ProcessHelper.cs similarity index 98% rename from app/ProcessHelper.cs rename to app/Helpers/ProcessHelper.cs index 2c762f97..0a5ed971 100644 --- a/app/ProcessHelper.cs +++ b/app/Helpers/ProcessHelper.cs @@ -6,7 +6,7 @@ using System.Security.Principal; using System.Text; using System.Threading.Tasks; -namespace GHelper +namespace GHelper.Helpers { public static class ProcessHelper { @@ -61,7 +61,8 @@ namespace GHelper { Process.Start(startInfo); Application.Exit(); - } catch (Exception ex) + } + catch (Exception ex) { Logger.WriteLine(ex.Message); } diff --git a/app/ScreenBrightness.cs b/app/Helpers/ScreenBrightness.cs similarity index 97% rename from app/ScreenBrightness.cs rename to app/Helpers/ScreenBrightness.cs index 4b06c940..9ea50222 100644 --- a/app/ScreenBrightness.cs +++ b/app/Helpers/ScreenBrightness.cs @@ -1,4 +1,4 @@ -namespace GHelper +namespace GHelper.Helpers { using System; using System.Diagnostics; diff --git a/app/Startup.cs b/app/Helpers/Startup.cs similarity index 98% rename from app/Startup.cs rename to app/Helpers/Startup.cs index f8da4539..ae6adc96 100644 --- a/app/Startup.cs +++ b/app/Helpers/Startup.cs @@ -1,4 +1,4 @@ -using GHelper; +using GHelper.Helpers; using Microsoft.Win32.TaskScheduler; using System.Diagnostics; using System.Security.Principal; diff --git a/app/ToastForm.cs b/app/Helpers/ToastForm.cs similarity index 84% rename from app/ToastForm.cs rename to app/Helpers/ToastForm.cs index 0b2c97ae..928de066 100644 --- a/app/ToastForm.cs +++ b/app/Helpers/ToastForm.cs @@ -1,9 +1,6 @@ -using OSD; -using System.Diagnostics; -using System.Drawing.Drawing2D; +using System.Drawing.Drawing2D; - -namespace GHelper +namespace GHelper.Helpers { static class Drawing @@ -74,7 +71,7 @@ namespace GHelper protected override void PerformPaint(PaintEventArgs e) { Brush brush = new SolidBrush(Color.FromArgb(150, Color.Black)); - Drawing.FillRoundedRectangle(e.Graphics, brush, this.Bound, 10); + e.Graphics.FillRoundedRectangle(brush, Bound, 10); StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; @@ -128,34 +125,37 @@ namespace GHelper e.Graphics.DrawString(toastText, new Font("Segoe UI", 36f, FontStyle.Bold, GraphicsUnit.Pixel), new SolidBrush(Color.White), - new PointF(this.Bound.Width / 2 + shiftX, this.Bound.Height / 2), + new PointF(Bound.Width / 2 + shiftX, Bound.Height / 2), format); } public void RunToast(string text, ToastIcon? icon = null) { - //Hide(); - timer.Stop(); + Program.settingsForm.Invoke(delegate + { + //Hide(); + timer.Stop(); - toastText = text; - toastIcon = icon; + toastText = text; + toastIcon = icon; - Screen screen1 = Screen.FromHandle(base.Handle); + Screen screen1 = Screen.FromHandle(Handle); - Width = Math.Max(300, 100 + toastText.Length * 22); - Height = 100; - X = (screen1.Bounds.Width - this.Width) / 2; - Y = screen1.Bounds.Height - 300 - this.Height; + Width = Math.Max(300, 100 + toastText.Length * 22); + Height = 100; + X = (screen1.Bounds.Width - Width) / 2; + Y = screen1.Bounds.Height - 300 - Height; + + Show(); + timer.Start(); + }); - Show(); - timer.Start(); } private void timer_Tick(object? sender, EventArgs e) { - Debug.WriteLine("Toast end"); - + //Debug.WriteLine("Toast end"); Hide(); timer.Stop(); } diff --git a/app/InputDispatcher.cs b/app/Input/InputDispatcher.cs similarity index 81% rename from app/InputDispatcher.cs rename to app/Input/InputDispatcher.cs index 10ba6a1a..1255a5c1 100644 --- a/app/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -1,54 +1,13 @@ -using HidLibrary; +using GHelper.Display; +using GHelper.Helpers; +using GHelper.Mode; using Microsoft.Win32; using NAudio.CoreAudioApi; using System.Diagnostics; using System.Management; -namespace GHelper +namespace GHelper.Input { - public class KeyboardListener - { - - CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - - public KeyboardListener(Action KeyHandler) - { - HidDevice? input = AsusUSB.GetDevice(); - if (input == null) return; - - Logger.WriteLine($"Input: {input.DevicePath}"); - - var task = Task.Run(() => - { - try - { - while (!cancellationTokenSource.Token.IsCancellationRequested) - { - var data = input.Read().Data; - if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0 && data[1] != 236) - { - Logger.WriteLine($"Key: {data[1]}"); - KeyHandler(data[1]); - } - } - Logger.WriteLine("Listener stopped"); - - } - catch (Exception ex) - { - Logger.WriteLine(ex.ToString()); - } - }); - - - } - - public void Dispose() - { - cancellationTokenSource?.Cancel(); - } - } - public class InputDispatcher { @@ -58,6 +17,9 @@ namespace GHelper public static Keys keyProfile = Keys.F5; public static Keys keyApp = Keys.F12; + static ModeControl modeControl = Program.modeControl; + static ScreenControl screenControl = new ScreenControl(); + KeyboardListener listener; KeyboardHook hook = new KeyboardHook(); @@ -123,8 +85,8 @@ namespace GHelper public void InitBacklightTimer() { - timer.Enabled = (AppConfig.Get("keyboard_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online) || - (AppConfig.Get("keyboard_ac_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online); + timer.Enabled = AppConfig.Get("keyboard_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online || + AppConfig.Get("keyboard_ac_timeout") > 0 && SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online; } @@ -145,7 +107,7 @@ namespace GHelper if (!AppConfig.ContainsModel("Z13")) if (actionM1 is not null && actionM1.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeDown); - if (actionM2 is not null && actionM2.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeUp); + if (actionM2 is not null && actionM2.Length > 0) hook.RegisterHotKey(ModifierKeys.None, Keys.VolumeUp); // FN-Lock group @@ -241,12 +203,12 @@ namespace GHelper break; case Keys.F7: if (AppConfig.ContainsModel("TUF")) - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, ScreenBrightness.Adjust(-10) + "%", ToastIcon.BrightnessDown); + Program.toast.RunToast(ScreenBrightness.Adjust(-10) + "%", ToastIcon.BrightnessDown); HandleOptimizationEvent(16); break; case Keys.F8: - if (AppConfig.ContainsModel("TUF")) - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, ScreenBrightness.Adjust(+10) + "%", ToastIcon.BrightnessUp); + if (AppConfig.ContainsModel("TUF")) + Program.toast.RunToast(ScreenBrightness.Adjust(+10) + "%", ToastIcon.BrightnessUp); HandleOptimizationEvent(32); break; case Keys.F9: @@ -274,7 +236,7 @@ namespace GHelper if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift)) { - if (e.Key == keyProfile) Program.settingsForm.CyclePerformanceMode(); + if (e.Key == keyProfile) modeControl.CyclePerformanceMode(); if (e.Key == keyApp) Program.SettingsToggle(); } @@ -316,13 +278,13 @@ namespace GHelper NativeMethods.TurnOffScreen(Program.settingsForm.Handle); break; case "miniled": - Program.settingsForm.BeginInvoke(Program.settingsForm.ToogleMiniled); + screenControl.ToogleMiniled(); break; case "aura": Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode); break; case "performance": - Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode); + modeControl.CyclePerformanceMode(); break; case "ghelper": Program.settingsForm.BeginInvoke(delegate @@ -339,7 +301,7 @@ namespace GHelper var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications); bool muteStatus = !commDevice.AudioEndpointVolume.Mute; commDevice.AudioEndpointVolume.Mute = muteStatus; - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone); + Program.toast.RunToast(muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone); } break; case "brightness_up": @@ -361,7 +323,7 @@ namespace GHelper { using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false)) { - return (key?.GetValue("Enabled")?.ToString() == "1"); + return key?.GetValue("Enabled")?.ToString() == "1"; } } @@ -371,11 +333,11 @@ namespace GHelper AppConfig.Set("fn_lock", fnLock); if (AppConfig.ContainsModel("VivoBook")) - Program.acpi.DeviceSet(AsusACPI.FnLock, (fnLock == 1) ? 0 : 1, "FnLock"); + Program.acpi.DeviceSet(AsusACPI.FnLock, fnLock == 1 ? 0 : 1, "FnLock"); else Program.settingsForm.BeginInvoke(Program.inputDispatcher.RegisterKeys); - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Fn-Lock "+(fnLock==1?"On":"Off"), ToastIcon.FnLock); + Program.toast.RunToast("Fn-Lock " + (fnLock == 1 ? "On" : "Off"), ToastIcon.FnLock); } public static void TabletMode() @@ -385,7 +347,7 @@ namespace GHelper Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState); - if ((tabletState && touchpadState) || (!tabletState && !touchpadState)) AsusUSB.TouchpadToggle(); + if (tabletState && touchpadState || !tabletState && !touchpadState) AsusUSB.TouchpadToggle(); } @@ -400,7 +362,7 @@ namespace GHelper KeyProcess("m4"); return; case 174: // FN+F5 - Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode); + modeControl.CyclePerformanceMode(); return; case 179: // FN+F4 case 178: // FN+F4 @@ -429,29 +391,28 @@ namespace GHelper return; } - if (!OptimizationService.IsRunning()) - + if (!OptimizationService.IsRunning()) HandleOptimizationEvent(EventID); - // Asus Optimization service Events - - } + // Asus Optimization service Events static void HandleOptimizationEvent(int EventID) { switch (EventID) { case 16: // FN+F7 + //ScreenBrightness.Adjust(-10); Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Down, "Brightness"); break; case 32: // FN+F8 + //ScreenBrightness.Adjust(+10); Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness"); break; case 107: // FN+F10 bool touchpadState = GetTouchpadState(); AsusUSB.TouchpadToggle(); - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad); + Program.toast.RunToast(touchpadState ? "Off" : "On", ToastIcon.Touchpad); break; case 108: // FN+F11 Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.KB_Sleep, "Sleep"); @@ -491,8 +452,8 @@ namespace GHelper int backlight = onBattery ? backlight_battery : backlight_power; if (delta >= 4) - backlight = (++backlight % 4); - else + backlight = ++backlight % 4; + else backlight = Math.Max(Math.Min(3, backlight + delta), 0); if (onBattery) @@ -504,7 +465,7 @@ namespace GHelper { AsusUSB.ApplyBrightness(backlight, "HotKey"); string[] backlightNames = new string[] { "Off", "Low", "Mid", "Max" }; - Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown); + Program.toast.RunToast(backlightNames[backlight], delta > 0 ? ToastIcon.BacklightUp : ToastIcon.BacklightDown); } } diff --git a/app/KeyboardHook.cs b/app/Input/KeyboardHook.cs similarity index 100% rename from app/KeyboardHook.cs rename to app/Input/KeyboardHook.cs diff --git a/app/Input/KeyboardListener.cs b/app/Input/KeyboardListener.cs new file mode 100644 index 00000000..6e182e9b --- /dev/null +++ b/app/Input/KeyboardListener.cs @@ -0,0 +1,56 @@ +using HidLibrary; + +namespace GHelper.Input +{ + public class KeyboardListener + { + + CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + + public KeyboardListener(Action KeyHandler) + { + HidDevice? input = AsusUSB.GetDevice(); + if (input == null) return; + + Logger.WriteLine($"Input: {input.DevicePath}"); + + var task = Task.Run(() => + { + try + { + while (!cancellationTokenSource.Token.IsCancellationRequested) + { + + // Emergency break + if (input == null || !input.IsConnected) + { + Logger.WriteLine("Listener terminated"); + break; + } + + var data = input.Read().Data; + if (data.Length > 1 && data[0] == AsusUSB.INPUT_HID_ID && data[1] > 0 && data[1] != 236) + { + Logger.WriteLine($"Key: {data[1]}"); + KeyHandler(data[1]); + } + } + + Logger.WriteLine("Listener stopped"); + + } + catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); + } + }); + + + } + + public void Dispose() + { + cancellationTokenSource?.Cancel(); + } + } +} diff --git a/app/Mode/ModeControl.cs b/app/Mode/ModeControl.cs new file mode 100644 index 00000000..f4e29596 --- /dev/null +++ b/app/Mode/ModeControl.cs @@ -0,0 +1,407 @@ +using GHelper.Gpu.NVidia; +using GHelper.Helpers; +using Ryzen; + +namespace GHelper.Mode +{ + public class ModeControl + { + + static SettingsForm settings = Program.settingsForm; + + private static bool customFans = false; + private static int customPower = 0; + + private int _cpuUV = 0; + private int _igpuUV = 0; + + static System.Timers.Timer reapplyTimer = default!; + + public ModeControl() + { + reapplyTimer = new System.Timers.Timer(AppConfig.GetMode("reapply_time", 30) * 1000); + reapplyTimer.Elapsed += ReapplyTimer_Elapsed; + reapplyTimer.Enabled = false; + } + + private void ReapplyTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e) + { + SetCPUTemp(AppConfig.GetMode("cpu_temp"), false); + } + + public void AutoPerformance(bool powerChanged = false) + { + var Plugged = SystemInformation.PowerStatus.PowerLineStatus; + + int mode = AppConfig.Get("performance_" + (int)Plugged); + + if (mode != -1) + SetPerformanceMode(mode, powerChanged); + else + SetPerformanceMode(Modes.GetCurrent()); + } + + + public void ResetPerformanceMode() + { + ResetRyzen(); + Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetCurrentBase(), "Mode"); + } + + public void SetPerformanceMode(int mode = -1, bool notify = false) + { + + int oldMode = Modes.GetCurrent(); + if (mode < 0) mode = oldMode; + + if (!Modes.Exists(mode)) mode = 0; + + customFans = false; + customPower = 0; + + settings.ShowMode(mode); + SetModeLabel(); + + Modes.SetCurrent(mode); + + Program.acpi.DeviceSet(AsusACPI.PerformanceMode, IsManualModeRequired() ? AsusACPI.PerformanceManual : Modes.GetBase(mode), "Mode"); + + if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM(); + + if (notify) + Program.toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery); + + SetGPUClocks(); + AutoFans(); + AutoPower(1000); + + if (AppConfig.Get("auto_apply_power_plan") != 0) + { + if (AppConfig.GetModeString("scheme") is not null) + PowerNative.SetPowerScheme(AppConfig.GetModeString("scheme")); + else + PowerNative.SetPowerScheme(Modes.GetBase(mode)); + } + + if (AppConfig.GetMode("auto_boost") != -1) + { + PowerNative.SetCPUBoost(AppConfig.GetMode("auto_boost")); + } + + /* + if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0) + { + Debug.WriteLine("Effective :" + activeScheme); + } + */ + + settings.FansInit(); + } + + + public void CyclePerformanceMode() + { + SetPerformanceMode(Modes.GetNext(Control.ModifierKeys == Keys.Shift), true); + } + + public void AutoFans(bool force = false) + { + customFans = false; + + if (AppConfig.IsMode("auto_apply") || force) + { + + bool xgmFan = false; + if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) + { + AsusUSB.SetXGMFan(AppConfig.GetFanConfig(AsusFan.XGM)); + xgmFan = true; + } + + int cpuResult = Program.acpi.SetFanCurve(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU)); + int gpuResult = Program.acpi.SetFanCurve(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU)); + + if (AppConfig.Is("mid_fan")) + Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.GetFanConfig(AsusFan.Mid)); + + + // something went wrong, resetting to default profile + if (cpuResult != 1 || gpuResult != 1) + { + int mode = Modes.GetCurrentBase(); + Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode); + Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode"); + settings.LabelFansResult("ASUS BIOS rejected fan curve"); + } + else + { + settings.LabelFansResult(""); + customFans = true; + } + + // force set PPTs for missbehaving bios on FX507/517 series + if ((AppConfig.ContainsModel("FX507") || AppConfig.ContainsModel("FX517") || xgmFan) && !AppConfig.IsMode("auto_apply_power")) + { + Task.Run(async () => + { + await Task.Delay(TimeSpan.FromSeconds(1)); + Program.acpi.DeviceSet(AsusACPI.PPT_TotalA0, 80, "PowerLimit Fix A0"); + Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, 80, "PowerLimit Fix A3"); + }); + } + + } + + SetModeLabel(); + + } + + private static bool IsManualModeRequired() + { + if (!AppConfig.IsMode("auto_apply_power")) + return false; + + return + AppConfig.Is("manual_mode") || + AppConfig.ContainsModel("GU603") || + AppConfig.ContainsModel("GU604") || + AppConfig.ContainsModel("G733"); + } + + public void AutoPower(int delay = 0) + { + + customPower = 0; + + bool applyPower = AppConfig.IsMode("auto_apply_power"); + bool applyFans = AppConfig.IsMode("auto_apply"); + //bool applyGPU = true; + + if (applyPower) + { + // force fan curve for misbehaving bios PPTs on G513 + if (AppConfig.ContainsModel("G513") && !applyFans) + { + delay = 500; + AutoFans(true); + } + + // Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them + if (IsManualModeRequired() && !applyFans) + { + AutoFans(true); + } + } + + if (delay > 0) + { + var timer = new System.Timers.Timer(delay); + timer.Elapsed += delegate + { + timer.Stop(); + timer.Dispose(); + + if (applyPower) SetPower(); + SetGPUPower(); + AutoRyzen(); + }; + timer.Start(); + } + else + { + if (applyPower) SetPower(true); + SetGPUPower(); + AutoRyzen(); + } + + } + + public void SetModeLabel() + { + settings.SetModeLabel(Properties.Strings.PerformanceMode + ": " + Modes.GetCurrentName() + (customFans ? "+" : "") + ((customPower > 0) ? " " + customPower + "W" : "")); + } + + public void SetPower(bool launchAsAdmin = false) + { + + int limit_total = AppConfig.GetMode("limit_total"); + int limit_cpu = AppConfig.GetMode("limit_cpu"); + int limit_fast = AppConfig.GetMode("limit_fast"); + + if (limit_total > AsusACPI.MaxTotal) return; + if (limit_total < AsusACPI.MinTotal) return; + + if (limit_cpu > AsusACPI.MaxCPU) return; + if (limit_cpu < AsusACPI.MinCPU) return; + + if (limit_fast > AsusACPI.MaxTotal) return; + if (limit_fast < AsusACPI.MinTotal) return; + + // SPL + SPPT togeher in one slider + if (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0) + { + Program.acpi.DeviceSet(AsusACPI.PPT_TotalA0, limit_total, "PowerLimit A0"); + Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, limit_total, "PowerLimit A3"); + customPower = limit_total; + } + else if (RyzenControl.IsAMD()) + { + + if (ProcessHelper.IsUserAdministrator()) + { + SendCommand.set_stapm_limit((uint)limit_total * 1000); + SendCommand.set_stapm2_limit((uint)limit_total * 1000); + SendCommand.set_slow_limit((uint)limit_total * 1000); + SendCommand.set_fast_limit((uint)limit_total * 1000); + customPower = limit_total; + } + else if (launchAsAdmin) + { + ProcessHelper.RunAsAdmin("cpu"); + return; + } + } + + if (Program.acpi.IsAllAmdPPT()) // CPU limit all amd models + { + Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, limit_cpu, "PowerLimit B0"); + customPower = limit_cpu; + } + else if (Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0) // FPPT boost for non all-amd models + { + Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, limit_fast, "PowerLimit C1"); + customPower = limit_fast; + } + + + SetModeLabel(); + + } + + public void SetGPUClocks(bool launchAsAdmin = true) + { + + int gpu_core = AppConfig.GetMode("gpu_core"); + int gpu_memory = AppConfig.GetMode("gpu_memory"); + + if (gpu_core == -1 && gpu_memory == -1) return; + + //if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false; + + if (Program.acpi.DeviceGet(AsusACPI.GPUEco) == 1) return; + if (HardwareControl.GpuControl is null) return; + if (!HardwareControl.GpuControl!.IsNvidia) return; + + using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl; + try + { + int getStatus = nvControl.GetClocks(out int current_core, out int current_memory); + if (getStatus != -1) + { + if (Math.Abs(gpu_core - current_core) < 5 && Math.Abs(gpu_memory - current_memory) < 5) return; + } + + int setStatus = nvControl.SetClocks(gpu_core, gpu_memory); + if (launchAsAdmin && setStatus == -1) ProcessHelper.RunAsAdmin("gpu"); + + } + catch (Exception ex) + { + Logger.WriteLine(ex.ToString()); + } + } + + public void SetGPUPower() + { + + int gpu_boost = AppConfig.GetMode("gpu_boost"); + int gpu_temp = AppConfig.GetMode("gpu_temp"); + + + if (gpu_boost < AsusACPI.MinGPUBoost || gpu_boost > AsusACPI.MaxGPUBoost) return; + if (gpu_temp < AsusACPI.MinGPUTemp || gpu_temp > AsusACPI.MaxGPUTemp) return; + + if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0) + Program.acpi.DeviceSet(AsusACPI.PPT_GPUC0, gpu_boost, "PowerLimit C0"); + + if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0) + Program.acpi.DeviceSet(AsusACPI.PPT_GPUC2, gpu_temp, "PowerLimit C2"); + + } + + public void SetCPUTemp(int? cpuTemp, bool log = true) + { + if (cpuTemp >= RyzenControl.MinTemp && cpuTemp <= RyzenControl.MaxTemp) + { + var resultCPU = SendCommand.set_tctl_temp((uint)cpuTemp); + if (log) Logger.WriteLine($"CPU Temp: {cpuTemp} {resultCPU}"); + + var restultAPU = SendCommand.set_apu_skin_temp_limit((uint)cpuTemp); + if (log) Logger.WriteLine($"APU Temp: {cpuTemp} {restultAPU}"); + + reapplyTimer.Enabled = AppConfig.IsMode("auto_uv"); + + } + else + { + reapplyTimer.Enabled = false; + } + } + + public void SetUV(int cpuUV) + { + if (cpuUV >= RyzenControl.MinCPUUV && cpuUV <= RyzenControl.MaxCPUUV) + { + var uvResult = SendCommand.set_coall(cpuUV); + Logger.WriteLine($"UV: {cpuUV} {uvResult}"); + if (uvResult == Smu.Status.OK) _cpuUV = cpuUV; + } + } + + public void SetUViGPU(int igpuUV) + { + if (igpuUV >= RyzenControl.MinIGPUUV && igpuUV <= RyzenControl.MaxIGPUUV) + { + var iGPUResult = SendCommand.set_cogfx(igpuUV); + Logger.WriteLine($"iGPU UV: {igpuUV} {iGPUResult}"); + if (iGPUResult == Smu.Status.OK) _igpuUV = igpuUV; + } + } + + + public void SetRyzen(bool launchAsAdmin = false) + { + if (!ProcessHelper.IsUserAdministrator()) + { + if (launchAsAdmin) ProcessHelper.RunAsAdmin("uv"); + return; + } + + try + { + SetUV(AppConfig.GetMode("cpu_uv", 0)); + SetUViGPU(AppConfig.GetMode("igpu_uv", 0)); + SetCPUTemp(AppConfig.GetMode("cpu_temp")); + } + catch (Exception ex) + { + Logger.WriteLine("UV Error: " + ex.ToString()); + } + } + + public void ResetRyzen() + { + if (_cpuUV != 0) SetUV(0); + if (_igpuUV != 0) SetUViGPU(0); + } + + public void AutoRyzen() + { + if (!RyzenControl.IsAMD()) return; + + if (AppConfig.IsMode("auto_uv")) SetRyzen(); + else ResetRyzen(); + } + + } +} diff --git a/app/Modes.cs b/app/Mode/Modes.cs similarity index 98% rename from app/Modes.cs rename to app/Mode/Modes.cs index 44266a82..9543c460 100644 --- a/app/Modes.cs +++ b/app/Mode/Modes.cs @@ -1,6 +1,4 @@ -using Microsoft.VisualBasic.Devices; - -namespace GHelper +namespace GHelper.Mode { internal class Modes { diff --git a/app/Mode/PowerNative.cs b/app/Mode/PowerNative.cs new file mode 100644 index 00000000..4153edb2 --- /dev/null +++ b/app/Mode/PowerNative.cs @@ -0,0 +1,161 @@ +using System.Runtime.InteropServices; + +namespace GHelper.Mode +{ + internal class PowerNative + { + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerWriteDCValueIndex(IntPtr RootPowerKey, + [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, + int AcValueIndex); + + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerWriteACValueIndex(IntPtr RootPowerKey, + [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, + int AcValueIndex); + + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey, + [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, + out IntPtr AcValueIndex + ); + + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerReadDCValueIndex(IntPtr RootPowerKey, + [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, + [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, + out IntPtr AcValueIndex + ); + + + [DllImport("powrprof.dll")] + static extern uint PowerReadACValue( + IntPtr RootPowerKey, + Guid SchemeGuid, + Guid SubGroupOfPowerSettingGuid, + Guid PowerSettingGuid, + ref int Type, + ref IntPtr Buffer, + ref uint BufferSize + ); + + + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey, + [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid); + + [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] + static extern UInt32 PowerGetActiveScheme(IntPtr UserPowerKey, out IntPtr ActivePolicyGuid); + + static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00"); + static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7"); + + private static Guid GUID_SLEEP_SUBGROUP = new Guid("238c9fa8-0aad-41ed-83f4-97be242c8f20"); + private static Guid GUID_HIBERNATEIDLE = new Guid("9d7815a6-7ee4-497e-8888-515a05f02364"); + + [DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetActualOverlayScheme")] + public static extern uint PowerGetActualOverlayScheme(out Guid ActualOverlayGuid); + + [DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetEffectiveOverlayScheme")] + public static extern uint PowerGetEffectiveOverlayScheme(out Guid EffectiveOverlayGuid); + + [DllImportAttribute("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")] + public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid); + + + static Guid GetActiveScheme() + { + IntPtr pActiveSchemeGuid; + var hr = PowerGetActiveScheme(IntPtr.Zero, out pActiveSchemeGuid); + Guid activeSchemeGuid = (Guid)Marshal.PtrToStructure(pActiveSchemeGuid, typeof(Guid)); + return activeSchemeGuid; + } + + public static int GetCPUBoost() + { + IntPtr AcValueIndex; + Guid activeSchemeGuid = GetActiveScheme(); + + UInt32 value = PowerReadACValueIndex(IntPtr.Zero, + activeSchemeGuid, + GUID_CPU, + GUID_BOOST, out AcValueIndex); + + return AcValueIndex.ToInt32(); + + } + + public static void SetCPUBoost(int boost = 0) + { + Guid activeSchemeGuid = GetActiveScheme(); + + if (boost == GetCPUBoost()) return; + + var hrAC = PowerWriteACValueIndex( + IntPtr.Zero, + activeSchemeGuid, + GUID_CPU, + GUID_BOOST, + boost); + + PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + + var hrDC = PowerWriteDCValueIndex( + IntPtr.Zero, + activeSchemeGuid, + GUID_CPU, + GUID_BOOST, + boost); + + PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); + + Logger.WriteLine("Boost " + boost); + } + + public static void SetPowerScheme(string scheme) + { + List overlays = new() { + "00000000-0000-0000-0000-000000000000", + "ded574b5-45a0-4f42-8737-46345c09c238", + "961cc777-2547-4f9d-8174-7d86181b8a7a", + "3af9B8d9-7c97-431d-ad78-34a8bfea439f" + }; + + if (overlays.Contains(scheme)) + { + PowerSetActiveOverlayScheme(new Guid(scheme)); + Logger.WriteLine("Power mode:" + scheme); + } + else + { + PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme)); + Logger.WriteLine("Power plan:" + scheme); + } + + + } + + public static void SetPowerScheme(int mode) + { + switch (mode) + { + case 0: // balanced + PowerSetActiveOverlayScheme(new Guid("00000000-0000-0000-0000-000000000000")); + break; + case 1: // turbo + PowerSetActiveOverlayScheme(new Guid("ded574b5-45a0-4f42-8737-46345c09c238")); + break; + case 2: //silent + PowerSetActiveOverlayScheme(new Guid("961cc777-2547-4f9d-8174-7d86181b8a7a")); + break; + } + } + } +} diff --git a/app/NativeMethods.cs b/app/NativeMethods.cs index 36d26f55..0b79204f 100644 --- a/app/NativeMethods.cs +++ b/app/NativeMethods.cs @@ -1,310 +1,5 @@ -using System.ComponentModel; -using System.Diagnostics; -using System.Runtime.InteropServices; -using static Tools.ScreenInterrogatory; +using System.Runtime.InteropServices; -namespace Tools -{ - - - public static class ScreenInterrogatory - { - public const int ERROR_SUCCESS = 0; - - #region enums - - public enum QUERY_DEVICE_CONFIG_FLAGS : uint - { - QDC_ALL_PATHS = 0x00000001, - QDC_ONLY_ACTIVE_PATHS = 0x00000002, - QDC_DATABASE_CURRENT = 0x00000004 - } - - public enum DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY : uint - { - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER = 0xFFFFFFFF, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15 = 0, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO = 2, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO = 3, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI = 4, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI = 5, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS = 6, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN = 8, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI = 9, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL = 10, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED = 11, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL = 12, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED = 13, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE = 14, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_MIRACAST = 15, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000, - DISPLAYCONFIG_OUTPUT_TECHNOLOGY_FORCE_UINT32 = 0xFFFFFFFF - } - - public enum DISPLAYCONFIG_SCANLINE_ORDERING : uint - { - DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0, - DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1, - DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2, - DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED, - DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3, - DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32 = 0xFFFFFFFF - } - - public enum DISPLAYCONFIG_ROTATION : uint - { - DISPLAYCONFIG_ROTATION_IDENTITY = 1, - DISPLAYCONFIG_ROTATION_ROTATE90 = 2, - DISPLAYCONFIG_ROTATION_ROTATE180 = 3, - DISPLAYCONFIG_ROTATION_ROTATE270 = 4, - DISPLAYCONFIG_ROTATION_FORCE_UINT32 = 0xFFFFFFFF - } - - public enum DISPLAYCONFIG_SCALING : uint - { - DISPLAYCONFIG_SCALING_IDENTITY = 1, - DISPLAYCONFIG_SCALING_CENTERED = 2, - DISPLAYCONFIG_SCALING_STRETCHED = 3, - DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX = 4, - DISPLAYCONFIG_SCALING_CUSTOM = 5, - DISPLAYCONFIG_SCALING_PREFERRED = 128, - DISPLAYCONFIG_SCALING_FORCE_UINT32 = 0xFFFFFFFF - } - - public enum DISPLAYCONFIG_PIXELFORMAT : uint - { - DISPLAYCONFIG_PIXELFORMAT_8BPP = 1, - DISPLAYCONFIG_PIXELFORMAT_16BPP = 2, - DISPLAYCONFIG_PIXELFORMAT_24BPP = 3, - DISPLAYCONFIG_PIXELFORMAT_32BPP = 4, - DISPLAYCONFIG_PIXELFORMAT_NONGDI = 5, - DISPLAYCONFIG_PIXELFORMAT_FORCE_UINT32 = 0xffffffff - } - - public enum DISPLAYCONFIG_MODE_INFO_TYPE : uint - { - DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, - DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, - DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF - } - - public enum DISPLAYCONFIG_DEVICE_INFO_TYPE : uint - { - DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, - DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, - DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, - DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, - DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF - } - - #endregion - - #region structs - - [StructLayout(LayoutKind.Sequential)] - public struct LUID - { - public uint LowPart; - public int HighPart; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_PATH_SOURCE_INFO - { - public LUID adapterId; - public uint id; - public uint modeInfoIdx; - public uint statusFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_PATH_TARGET_INFO - { - public LUID adapterId; - public uint id; - public uint modeInfoIdx; - private DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; - private DISPLAYCONFIG_ROTATION rotation; - private DISPLAYCONFIG_SCALING scaling; - private DISPLAYCONFIG_RATIONAL refreshRate; - private DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; - public bool targetAvailable; - public uint statusFlags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_RATIONAL - { - public uint Numerator; - public uint Denominator; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_PATH_INFO - { - public DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; - public DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; - public uint flags; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_2DREGION - { - public uint cx; - public uint cy; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO - { - public ulong pixelRate; - public DISPLAYCONFIG_RATIONAL hSyncFreq; - public DISPLAYCONFIG_RATIONAL vSyncFreq; - public DISPLAYCONFIG_2DREGION activeSize; - public DISPLAYCONFIG_2DREGION totalSize; - public uint videoStandard; - public DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_TARGET_MODE - { - public DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; - } - - [StructLayout(LayoutKind.Sequential)] - public struct POINTL - { - private int x; - private int y; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_SOURCE_MODE - { - public uint width; - public uint height; - public DISPLAYCONFIG_PIXELFORMAT pixelFormat; - public POINTL position; - } - - [StructLayout(LayoutKind.Explicit)] - public struct DISPLAYCONFIG_MODE_INFO_UNION - { - [FieldOffset(0)] - public DISPLAYCONFIG_TARGET_MODE targetMode; - - [FieldOffset(0)] - public DISPLAYCONFIG_SOURCE_MODE sourceMode; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_MODE_INFO - { - public DISPLAYCONFIG_MODE_INFO_TYPE infoType; - public uint id; - public LUID adapterId; - public DISPLAYCONFIG_MODE_INFO_UNION modeInfo; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS - { - public uint value; - } - - [StructLayout(LayoutKind.Sequential)] - public struct DISPLAYCONFIG_DEVICE_INFO_HEADER - { - public DISPLAYCONFIG_DEVICE_INFO_TYPE type; - public uint size; - public LUID adapterId; - public uint id; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct DISPLAYCONFIG_TARGET_DEVICE_NAME - { - public DISPLAYCONFIG_DEVICE_INFO_HEADER header; - public DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; - public DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY outputTechnology; - public ushort edidManufactureId; - public ushort edidProductCodeId; - public uint connectorInstance; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] - public string monitorFriendlyDeviceName; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public string monitorDevicePath; - } - - #endregion - - #region DLL-Imports - - [DllImport("user32.dll")] - public static extern int GetDisplayConfigBufferSizes( - QUERY_DEVICE_CONFIG_FLAGS flags, out uint numPathArrayElements, out uint numModeInfoArrayElements); - - [DllImport("user32.dll")] - public static extern int QueryDisplayConfig( - QUERY_DEVICE_CONFIG_FLAGS flags, - ref uint numPathArrayElements, [Out] DISPLAYCONFIG_PATH_INFO[] PathInfoArray, - ref uint numModeInfoArrayElements, [Out] DISPLAYCONFIG_MODE_INFO[] ModeInfoArray, - IntPtr currentTopologyId - ); - - [DllImport("user32.dll")] - public static extern int DisplayConfigGetDeviceInfo(ref DISPLAYCONFIG_TARGET_DEVICE_NAME deviceName); - - #endregion - - private static DISPLAYCONFIG_TARGET_DEVICE_NAME DeviceName(LUID adapterId, uint targetId) - { - var deviceName = new DISPLAYCONFIG_TARGET_DEVICE_NAME - { - header = - { - size = (uint)Marshal.SizeOf(typeof (DISPLAYCONFIG_TARGET_DEVICE_NAME)), - adapterId = adapterId, - id = targetId, - type = DISPLAYCONFIG_DEVICE_INFO_TYPE.DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME - } - }; - var error = DisplayConfigGetDeviceInfo(ref deviceName); - if (error != ERROR_SUCCESS) - throw new Win32Exception(error); - - return deviceName; - } - - public static IEnumerable GetAllDevices() - { - uint pathCount, modeCount; - var error = GetDisplayConfigBufferSizes(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS, out pathCount, out modeCount); - if (error != ERROR_SUCCESS) - throw new Win32Exception(error); - - var displayPaths = new DISPLAYCONFIG_PATH_INFO[pathCount]; - var displayModes = new DISPLAYCONFIG_MODE_INFO[modeCount]; - error = QueryDisplayConfig(QUERY_DEVICE_CONFIG_FLAGS.QDC_ONLY_ACTIVE_PATHS, - ref pathCount, displayPaths, ref modeCount, displayModes, IntPtr.Zero); - if (error != ERROR_SUCCESS) - throw new Win32Exception(error); - - for (var i = 0; i < modeCount; i++) - if (displayModes[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE.DISPLAYCONFIG_MODE_INFO_TYPE_TARGET) - yield return DeviceName(displayModes[i].adapterId, displayModes[i].id); - } - - - } - -} public class NativeMethods { @@ -327,9 +22,6 @@ public class NativeMethods } - [DllImport("User32.dll")] - public static extern bool SetForegroundWindow(IntPtr handle); - private const int WM_SYSCOMMAND = 0x0112; private const int SC_MONITORPOWER = 0xF170; private const int MONITOR_OFF = 2; @@ -414,430 +106,5 @@ public class NativeMethods } - [DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)] - public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent); - - [DllImport("user32.dll")] - public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - public const int SW_RESTORE = 9; - - public static bool SwitchToCurrent() - { - IntPtr hWnd = IntPtr.Zero; - Process process = Process.GetCurrentProcess(); - Process[] processes = Process.GetProcessesByName(process.ProcessName); - foreach (Process _process in processes) - { - if (_process.Id != process.Id) - { - - if (_process.MainWindowHandle != IntPtr.Zero) - { - Debug.WriteLine(_process.Id); - Debug.WriteLine(process.Id); - - hWnd = _process.MainWindowHandle; - ShowWindowAsync(hWnd, SW_RESTORE); - } - - return true; - break; - } - } - - return false; - } - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerWriteDCValueIndex(IntPtr RootPowerKey, - [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, - int AcValueIndex); - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerWriteACValueIndex(IntPtr RootPowerKey, - [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, - int AcValueIndex); - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey, - [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, - out IntPtr AcValueIndex - ); - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerReadDCValueIndex(IntPtr RootPowerKey, - [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid, - [MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid, - out IntPtr AcValueIndex - ); - - - [DllImport("powrprof.dll")] - static extern uint PowerReadACValue( - IntPtr RootPowerKey, - Guid SchemeGuid, - Guid SubGroupOfPowerSettingGuid, - Guid PowerSettingGuid, - ref int Type, - ref IntPtr Buffer, - ref uint BufferSize - ); - - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey, - [MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid); - - [DllImport("PowrProf.dll", CharSet = CharSet.Unicode)] - static extern UInt32 PowerGetActiveScheme(IntPtr UserPowerKey, out IntPtr ActivePolicyGuid); - - static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00"); - static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7"); - - private static Guid GUID_SLEEP_SUBGROUP = new Guid("238c9fa8-0aad-41ed-83f4-97be242c8f20"); - private static Guid GUID_HIBERNATEIDLE = new Guid("9d7815a6-7ee4-497e-8888-515a05f02364"); - - [DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetActualOverlayScheme")] - public static extern uint PowerGetActualOverlayScheme(out Guid ActualOverlayGuid); - - [DllImportAttribute("powrprof.dll", EntryPoint = "PowerGetEffectiveOverlayScheme")] - public static extern uint PowerGetEffectiveOverlayScheme(out Guid EffectiveOverlayGuid); - - [DllImportAttribute("powrprof.dll", EntryPoint = "PowerSetActiveOverlayScheme")] - public static extern uint PowerSetActiveOverlayScheme(Guid OverlaySchemeGuid); - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public struct DEVMODE - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string dmDeviceName; - - public short dmSpecVersion; - public short dmDriverVersion; - public short dmSize; - public short dmDriverExtra; - public int dmFields; - public int dmPositionX; - public int dmPositionY; - public int dmDisplayOrientation; - public int dmDisplayFixedOutput; - public short dmColor; - public short dmDuplex; - public short dmYResolution; - public short dmTTOption; - public short dmCollate; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string dmFormName; - - public short dmLogPixels; - public short dmBitsPerPel; - public int dmPelsWidth; - public int dmPelsHeight; - public int dmDisplayFlags; - public int dmDisplayFrequency; - public int dmICMMethod; - public int dmICMIntent; - public int dmMediaType; - public int dmDitherType; - public int dmReserved1; - public int dmReserved2; - public int dmPanningWidth; - public int dmPanningHeight; - }; - - [Flags()] - public enum DisplaySettingsFlags : int - { - CDS_UPDATEREGISTRY = 1, - CDS_TEST = 2, - CDS_FULLSCREEN = 4, - CDS_GLOBAL = 8, - CDS_SET_PRIMARY = 0x10, - CDS_RESET = 0x40000000, - CDS_NORESET = 0x10000000 - } - - // PInvoke declaration for EnumDisplaySettings Win32 API - [DllImport("user32.dll")] - public static extern int EnumDisplaySettingsEx( - string lpszDeviceName, - int iModeNum, - ref DEVMODE lpDevMode); - - // PInvoke declaration for ChangeDisplaySettings Win32 API - [DllImport("user32.dll")] - public static extern int ChangeDisplaySettingsEx( - string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd, - DisplaySettingsFlags dwflags, IntPtr lParam); - - public static DEVMODE CreateDevmode() - { - DEVMODE dm = new DEVMODE(); - dm.dmDeviceName = new String(new char[32]); - dm.dmFormName = new String(new char[32]); - dm.dmSize = (short)Marshal.SizeOf(dm); - return dm; - } - - public enum COLORPROFILETYPE - { - CPT_ICC, - CPT_DMP, - CPT_CAMP, - CPT_GMMP - } - public enum COLORPROFILESUBTYPE - { - CPST_PERCEPTUAL, - CPST_RELATIVE_COLORIMETRIC, - CPST_SATURATION, - CPST_ABSOLUTE_COLORIMETRIC, - CPST_NONE, - CPST_RGB_WORKING_SPACE, - CPST_CUSTOM_WORKING_SPACE, - CPST_STANDARD_DISPLAY_COLOR_MODE, - CPST_EXTENDED_DISPLAY_COLOR_MODE - } - public enum WCS_PROFILE_MANAGEMENT_SCOPE - { - WCS_PROFILE_MANAGEMENT_SCOPE_SYSTEM_WIDE, - WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER - } - - [DllImport("mscms.dll", CharSet = CharSet.Unicode)] - public static extern bool WcsSetDefaultColorProfile( - WCS_PROFILE_MANAGEMENT_SCOPE scope, - string pDeviceName, - COLORPROFILETYPE cptColorProfileType, - COLORPROFILESUBTYPE cpstColorProfileSubType, - uint dwProfileID, - string pProfileName - ); - - - public const int ENUM_CURRENT_SETTINGS = -1; - public const string defaultDevice = "\\\\.\\DISPLAY1"; - - public static string FindLaptopScreen() - { - string laptopScreen = null; - - try - { - var devices = GetAllDevices().ToArray(); - int count = 0, displayNum = -1; - - string internalName = AppConfig.GetString("internal_display"); - - foreach (var device in devices) - { - if (device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL || - device.outputTechnology == DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY.DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED || - device.monitorFriendlyDeviceName == internalName) - { - displayNum = count; - AppConfig.Set("internal_display", device.monitorFriendlyDeviceName); - } - count++; - //Logger.WriteLine(device.monitorFriendlyDeviceName + ":" + device.outputTechnology.ToString()); - } - - var screens = Screen.AllScreens; - - if (screens.Length != count) return null; - - count = 0; - foreach (var screen in screens) - { - if (count == displayNum) - { - laptopScreen = screen.DeviceName; - } - //Logger.WriteLine(screen.DeviceName); - count++; - } - - if (displayNum > 0 && count == 0) laptopScreen = defaultDevice; - } - catch (Exception ex) - { - Logger.WriteLine(ex.ToString()); - Logger.WriteLine("Can't detect internal screen"); - laptopScreen = Screen.PrimaryScreen.DeviceName; - } - - - return laptopScreen; - } - - public static int GetRefreshRate(bool max = false) - { - DEVMODE dm = CreateDevmode(); - - string laptopScreen = FindLaptopScreen(); - int frequency = -1; - - if (laptopScreen is null) - return -1; - - if (max) - { - int i = 0; - while (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, i, ref dm)) - { - if (dm.dmDisplayFrequency > frequency) frequency = dm.dmDisplayFrequency; - i++; - } - } - else - { - if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) - { - frequency = dm.dmDisplayFrequency; - } - } - - - return frequency; - } - - public static int SetRefreshRate(int frequency = 120) - { - DEVMODE dm = CreateDevmode(); - string laptopScreen = FindLaptopScreen(); - - if (laptopScreen is null) - return -1; - - if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) - { - dm.dmDisplayFrequency = frequency; - int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); - Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); - - //Fallback scenario - if (iRet != 0) - { - Thread.Sleep(300); - iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); - Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); - } - - return iRet; - } - - return 0; - - } - - public static nint GetHuibernateAfter() - { - Guid activePolicyGuid = GetActiveScheme(); - var type = 0; - nint value = 0; - var valueSize = 4u; - - PowerReadACValue(IntPtr.Zero, activePolicyGuid, - GUID_SLEEP_SUBGROUP, GUID_HIBERNATEIDLE, - ref type, ref value, ref valueSize); - - return value; - } - - static Guid GetActiveScheme() - { - IntPtr pActiveSchemeGuid; - var hr = PowerGetActiveScheme(IntPtr.Zero, out pActiveSchemeGuid); - Guid activeSchemeGuid = (Guid)Marshal.PtrToStructure(pActiveSchemeGuid, typeof(Guid)); - return activeSchemeGuid; - } - - public static int GetCPUBoost() - { - IntPtr AcValueIndex; - Guid activeSchemeGuid = GetActiveScheme(); - - UInt32 value = PowerReadACValueIndex(IntPtr.Zero, - activeSchemeGuid, - GUID_CPU, - GUID_BOOST, out AcValueIndex); - - return AcValueIndex.ToInt32(); - - } - - public static void SetCPUBoost(int boost = 0) - { - Guid activeSchemeGuid = GetActiveScheme(); - - if (boost == GetCPUBoost()) return; - - var hrAC = PowerWriteACValueIndex( - IntPtr.Zero, - activeSchemeGuid, - GUID_CPU, - GUID_BOOST, - boost); - - PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); - - var hrDC = PowerWriteDCValueIndex( - IntPtr.Zero, - activeSchemeGuid, - GUID_CPU, - GUID_BOOST, - boost); - - PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); - - Logger.WriteLine("Boost " + boost); - } - - public static void SetPowerScheme(string scheme) - { - List overlays = new() { - "00000000-0000-0000-0000-000000000000", - "ded574b5-45a0-4f42-8737-46345c09c238", - "961cc777-2547-4f9d-8174-7d86181b8a7a", - "3af9B8d9-7c97-431d-ad78-34a8bfea439f" - }; - - if (overlays.Contains(scheme)) - { - PowerSetActiveOverlayScheme(new Guid(scheme)); - Logger.WriteLine("Power mode:" + scheme); - } - else - { - PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme)); - Logger.WriteLine("Power plan:" + scheme); - } - - - } - - public static void SetPowerScheme(int mode) - { - switch (mode) - { - case 0: // balanced - PowerSetActiveOverlayScheme(new Guid("00000000-0000-0000-0000-000000000000")); - break; - case 1: // turbo - PowerSetActiveOverlayScheme(new Guid("ded574b5-45a0-4f42-8737-46345c09c238")); - break; - case 2: //silent - PowerSetActiveOverlayScheme(new Guid("961cc777-2547-4f9d-8174-7d86181b8a7a")); - break; - } - } } diff --git a/app/NvAPIWrapper/Display/ColorData.cs b/app/NvAPIWrapper/Display/ColorData.cs deleted file mode 100644 index c856d815..00000000 --- a/app/NvAPIWrapper/Display/ColorData.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - public class ColorData : IColorData, IEquatable - { - /// - /// Creates an instance of to modify the color data - /// - /// The color data color format. - /// The color data color space. - /// The color data dynamic range. - /// The color data color depth. - /// The color data selection policy. - /// The color data desktop color depth. - public ColorData( - ColorDataFormat colorFormat = ColorDataFormat.Auto, - ColorDataColorimetry colorimetry = ColorDataColorimetry.Auto, - ColorDataDynamicRange? dynamicRange = null, - ColorDataDepth? colorDepth = null, - ColorDataSelectionPolicy? colorSelectionPolicy = null, - ColorDataDesktopDepth? desktopColorDepth = null - ) - { - ColorFormat = colorFormat; - Colorimetry = colorimetry; - DynamicRange = dynamicRange; - ColorDepth = colorDepth; - SelectionPolicy = colorSelectionPolicy; - DesktopColorDepth = desktopColorDepth; - } - - internal ColorData(IColorData colorData) - { - ColorDepth = colorData.ColorDepth; - DynamicRange = colorData.DynamicRange; - ColorFormat = colorData.ColorFormat; - Colorimetry = colorData.Colorimetry; - SelectionPolicy = colorData.SelectionPolicy; - DesktopColorDepth = colorData.DesktopColorDepth; - } - - /// - public ColorDataDepth? ColorDepth { get; } - - /// - public ColorDataFormat ColorFormat { get; } - - /// - public ColorDataColorimetry Colorimetry { get; } - - /// - public ColorDataDesktopDepth? DesktopColorDepth { get; } - - /// - public ColorDataDynamicRange? DynamicRange { get; } - - /// - public ColorDataSelectionPolicy? SelectionPolicy { get; } - - /// - public bool Equals(ColorData other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return ColorDepth == other.ColorDepth && - ColorFormat == other.ColorFormat && - Colorimetry == other.Colorimetry && - DesktopColorDepth == other.DesktopColorDepth && - DynamicRange == other.DynamicRange && - SelectionPolicy == other.SelectionPolicy; - } - - /// - /// Compares two instances of for equality. - /// - /// The first instance. - /// The second instance. - /// true if two instances are equal; otherwise false. - public static bool operator ==(ColorData left, ColorData right) - { - return left?.Equals(right) == true; - } - - /// - /// Compares two instances of for inequality. - /// - /// The first instance. - /// The second instance. - /// true if two instances are not equal; otherwise false. - public static bool operator !=(ColorData left, ColorData right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((ColorData) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = ColorDepth.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) ColorFormat; - hashCode = (hashCode * 397) ^ (int) Colorimetry; - hashCode = (hashCode * 397) ^ DesktopColorDepth.GetHashCode(); - hashCode = (hashCode * 397) ^ DynamicRange.GetHashCode(); - hashCode = (hashCode * 397) ^ SelectionPolicy.GetHashCode(); - - return hashCode; - } - } - - internal ColorDataV1 AsColorDataV1(ColorDataCommand command) - { - return new ColorDataV1( - command, - ColorFormat, - Colorimetry - ); - } - - internal ColorDataV2 AsColorDataV2(ColorDataCommand command) - { - return new ColorDataV2( - command, - ColorFormat, - Colorimetry, - DynamicRange ?? ColorDataDynamicRange.Auto - ); - } - - internal ColorDataV3 AsColorDataV3(ColorDataCommand command) - { - return new ColorDataV3( - command, - ColorFormat, - Colorimetry, - DynamicRange ?? ColorDataDynamicRange.Auto, - ColorDepth ?? ColorDataDepth.Default - ); - } - - internal ColorDataV4 AsColorDataV4(ColorDataCommand command) - { - return new ColorDataV4( - command, - ColorFormat, - Colorimetry, - DynamicRange ?? ColorDataDynamicRange.Auto, - ColorDepth ?? ColorDataDepth.Default, - SelectionPolicy ?? ColorDataSelectionPolicy.Default - ); - } - - internal ColorDataV5 AsColorDataV5(ColorDataCommand command) - { - return new ColorDataV5( - command, - ColorFormat, - Colorimetry, - DynamicRange ?? ColorDataDynamicRange.Auto, - ColorDepth ?? ColorDataDepth.Default, - SelectionPolicy ?? ColorDataSelectionPolicy.Default, - DesktopColorDepth ?? ColorDataDesktopDepth.Default - ); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/CustomResolution.cs b/app/NvAPIWrapper/Display/CustomResolution.cs deleted file mode 100644 index 8dac9a47..00000000 --- a/app/NvAPIWrapper/Display/CustomResolution.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Display -{ - /// - /// Hold information about a custom display resolution - /// - public class CustomResolution : IEquatable - { - /// - /// Creates an instance of . - /// - /// The screen width. - /// The screen height. - /// The color format. - /// The resolution timing. - /// The horizontal scaling ratio. - /// The vertical scaling ratio. - public CustomResolution( - uint width, - uint height, - ColorFormat colorFormat, - Timing timing, - float xRatio = 1, - float yRatio = 1 - ) - { - if (xRatio <= 0) - { - throw new ArgumentOutOfRangeException(nameof(xRatio)); - } - - if (yRatio <= 0) - { - throw new ArgumentOutOfRangeException(nameof(yRatio)); - } - - Width = width; - Height = height; - ColorFormat = colorFormat; - XRatio = xRatio; - YRatio = yRatio; - Timing = timing; - - switch (ColorFormat) - { - case ColorFormat.P8: - ColorDepth = 8; - - break; - case ColorFormat.R5G6B5: - ColorDepth = 16; - - break; - case ColorFormat.A8R8G8B8: - ColorDepth = 24; - - break; - case ColorFormat.A16B16G16R16F: - ColorDepth = 32; - - break; - default: - throw new ArgumentException("Color format is invalid.", nameof(colorFormat)); - } - } - - /// - /// Creates an instance of . - /// - /// The screen width. - /// The screen height. - /// The color depth. - /// The resolution timing. - /// The horizontal scaling ratio. - /// The vertical scaling ratio. - public CustomResolution( - uint width, - uint height, - uint colorDepth, - Timing timing, - float xRatio = 1, - float yRatio = 1) - { - if (xRatio <= 0) - { - throw new ArgumentOutOfRangeException(nameof(xRatio)); - } - - if (yRatio <= 0) - { - throw new ArgumentOutOfRangeException(nameof(yRatio)); - } - - if (colorDepth != 0 && colorDepth != 8 && colorDepth != 16 && colorDepth != 24 && colorDepth != 32) - { - throw new ArgumentOutOfRangeException(nameof(colorDepth)); - } - - Width = width; - Height = height; - ColorDepth = colorDepth; - ColorFormat = ColorFormat.Unknown; - XRatio = xRatio; - YRatio = yRatio; - Timing = timing; - } - - internal CustomResolution(CustomDisplay customDisplay) - { - Width = customDisplay.Width; - Height = customDisplay.Height; - ColorDepth = customDisplay.Depth; - ColorFormat = customDisplay.ColorFormat; - Timing = customDisplay.Timing; - XRatio = customDisplay.XRatio; - YRatio = customDisplay.YRatio; - } - - /// - /// Gets the source surface color depth. "0" means all 8/16/32bpp. - /// - public uint ColorDepth { get; } - - /// - /// Gets the color format (optional) - /// - public ColorFormat ColorFormat { get; } - - /// - /// Gets the source surface (source mode) height. - /// - public uint Height { get; } - - /// - /// Gets the timing used to program TMDS/DAC/LVDS/HDMI/TVEncoder, etc. - /// - public Timing Timing { get; } - - /// - /// Gets the source surface (source mode) width. - /// - public uint Width { get; } - - /// - /// Gets the horizontal scaling ratio. - /// - public float XRatio { get; } - - /// - /// Gets the vertical scaling ratio. - /// - public float YRatio { get; } - - /// - public bool Equals(CustomResolution other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Width == other.Width && - Height == other.Height && - ColorDepth == other.ColorDepth && - Timing.Equals(other.Timing) && - ColorFormat == other.ColorFormat && - XRatio.Equals(other.XRatio) && - YRatio.Equals(other.YRatio); - } - - /// - /// Compares two instance of for equality. - /// - /// An first instance of to compare. - /// An Second instance of to compare. - /// True if both instances are equal, otherwise false. - public static bool operator ==(CustomResolution left, CustomResolution right) - { - return Equals(left, right); - } - - /// - /// Compares two instance of for inequality. - /// - /// An first instance of to compare. - /// An Second instance of to compare. - /// True if both instances are not equal, otherwise false. - public static bool operator !=(CustomResolution left, CustomResolution right) - { - return !Equals(left, right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((CustomResolution) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) Width; - hashCode = (hashCode * 397) ^ (int) Height; - hashCode = (hashCode * 397) ^ (int) ColorDepth; - hashCode = (hashCode * 397) ^ Timing.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) ColorFormat; - hashCode = (hashCode * 397) ^ XRatio.GetHashCode(); - hashCode = (hashCode * 397) ^ YRatio.GetHashCode(); - - return hashCode; - } - } - - internal CustomDisplay AsCustomDisplay(bool hardwareModeSetOnly) - { - return new CustomDisplay(Width, Height, ColorDepth, ColorFormat, XRatio, YRatio, Timing, - hardwareModeSetOnly); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/DVCInformation.cs b/app/NvAPIWrapper/Display/DVCInformation.cs deleted file mode 100644 index c5a4da3f..00000000 --- a/app/NvAPIWrapper/Display/DVCInformation.cs +++ /dev/null @@ -1,325 +0,0 @@ -using System; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - /// This class contains and provides a way to modify the Digital Vibrance Control information regarding the - /// saturation level of the display or the output - /// - public class DVCInformation : IDisplayDVCInfo - { - private readonly DisplayHandle _displayHandle = DisplayHandle.DefaultHandle; - private readonly OutputId _outputId = OutputId.Invalid; - private bool? _isLegacy; - - /// - /// Creates a new instance of the class using a DisplayHandle - /// - /// The handle of the display. - public DVCInformation(DisplayHandle displayHandle) - { - _displayHandle = displayHandle; - } - - /// - /// Creates a new instance of this class using a OutputId - /// - /// The output identification of a display or an output - public DVCInformation(OutputId outputId) - { - _outputId = outputId; - } - - /// - /// Gets and sets the normalized saturation level in the [-1,1] inclusive range. - /// a -1 value corresponds to the minimum saturation level and maximum under-saturation and the - /// a 1 value corresponds to the maximum saturation level and maximum over-saturation. - /// The value of 0 indicates the default saturation level. - /// - public double NormalizedLevel - { - get - { - var info = GetInfo(); - - if (info == null) - { - return double.NaN; - } - - var deviance = info.CurrentLevel - info.DefaultLevel; - var range = deviance >= 0 - ? info.MaximumLevel - info.DefaultLevel - : info.DefaultLevel - info.MinimumLevel; - - if (deviance == 0 || range == 0) - { - return 0; - } - - return Math.Max(Math.Min((double) deviance / range, 1), -1); - } - set - { - if (double.IsNaN(value) || double.IsInfinity(value)) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - var info = GetInfo(); - - if (info == null) - { - return; - } - - var range = value >= 0 ? info.MaximumLevel - info.DefaultLevel : info.DefaultLevel - info.MinimumLevel; - var level = Math.Max(Math.Min((int) (value * range) + info.DefaultLevel, info.MaximumLevel), info.MinimumLevel); - - if (level == info.CurrentLevel) - { - return; - } - - SetLevel(level); - } - } - - /// - /// Gets and sets the current saturation level - /// - public int CurrentLevel - { - get => GetInfo()?.CurrentLevel ?? 0; - set - { - var info = GetInfo(); - - if (info == null) - { - return; - } - - value = Math.Max(Math.Min(value, info.MaximumLevel), info.MinimumLevel); - - if (info.CurrentLevel == value) - { - return; - } - - SetLevel(value); - } - } - - /// - public int DefaultLevel - { - get => GetInfo()?.DefaultLevel ?? 0; - } - - /// - public int MaximumLevel - { - get => GetInfo()?.MaximumLevel ?? 0; - } - - /// - public int MinimumLevel - { - get => GetInfo()?.MinimumLevel ?? 0; - } - - /// - public override string ToString() - { - return - $"{CurrentLevel:D} @ [{MinimumLevel:D} <= {DefaultLevel:D} <= {MaximumLevel:D}] = {NormalizedLevel:F2}"; - } - - private IDisplayDVCInfo GetInfo() - { - if (_isLegacy == true) - { - return GetLegacyInfo(); - } - - if (_isLegacy == false) - { - return GetModernInfo(); - } - - var info = GetModernInfo() ?? GetLegacyInfo(); - - if (info == null) - { - // exception occured on both, force a mode - _isLegacy = false; - - return GetInfo(); - } - - return info; - } - - private IDisplayDVCInfo GetLegacyInfo() - { - try - { - var info = _outputId == OutputId.Invalid - ? DisplayApi.GetDVCInfo(_displayHandle) - : DisplayApi.GetDVCInfo(_outputId); - - if (info.MaximumLevel == 0 && info.MinimumLevel == 0 && info.CurrentLevel == 0) - { - return null; - } - - if (!_isLegacy.HasValue) - { - _isLegacy = true; - } - - - return info; - } - catch (Exception) - { - if (_isLegacy == true) - { - throw; - } - - // ignore - } - - return null; - } - - private IDisplayDVCInfo GetModernInfo() - { - try - { - var info = _outputId == OutputId.Invalid - ? DisplayApi.GetDVCInfoEx(_displayHandle) - : DisplayApi.GetDVCInfoEx(_outputId); - - if (info.MaximumLevel == 0 && info.MinimumLevel == 0 && info.CurrentLevel == 0) - { - return null; - } - - if (!_isLegacy.HasValue) - { - _isLegacy = false; - } - - return info; - } - catch (Exception) - { - if (_isLegacy == false) - { - throw; - } - - // ignore - } - - return null; - } - - private bool SetLegacyLevel(int level) - { - try - { - if (_outputId == OutputId.Invalid) - { - DisplayApi.SetDVCLevel(_displayHandle, level); - } - else - { - DisplayApi.SetDVCLevel(_outputId, level); - } - - if (!_isLegacy.HasValue) - { - _isLegacy = true; - } - - return true; - } - catch (Exception) - { - if (_isLegacy == true) - { - throw; - } - - // ignore - } - - return false; - } - - private void SetLevel(int level) - { - if (_isLegacy == true) - { - SetLegacyLevel(level); - } - else if (_isLegacy == false) - { - SetModernLevel(level); - } - else - { - var success = SetModernLevel(level) || SetLegacyLevel(level); - - if (!success) - { - // exception occured on both, force a mode - _isLegacy = false; - - SetLevel(level); - } - } - } - - private bool SetModernLevel(int level) - { - try - { - if (_outputId == OutputId.Invalid) - { - DisplayApi.SetDVCLevelEx(_displayHandle, level); - } - else - { - DisplayApi.SetDVCLevelEx(_outputId, level); - } - - if (!_isLegacy.HasValue) - { - _isLegacy = false; - } - - return true; - } - catch (Exception) - { - if (_isLegacy == false) - { - throw; - } - - // ignore - } - - return false; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/Display.cs b/app/NvAPIWrapper/Display/Display.cs deleted file mode 100644 index 4da92f77..00000000 --- a/app/NvAPIWrapper/Display/Display.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.GPU; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents an attached display - /// - public class Display : IEquatable - { - /// - /// Creates a new Display - /// - /// Handle of the display device - public Display(DisplayHandle handle) - { - Handle = handle; - } - - /// - /// Creates a new Display - /// - /// Name of the display device - public Display(string displayName) - { - Handle = DisplayApi.GetAssociatedNvidiaDisplayHandle(displayName); - } - - /// - /// Gets the corresponding Digital Vibrance Control information - /// - public DVCInformation DigitalVibranceControl - { - get => new DVCInformation(Handle); - } - - /// - /// Gets corresponding DisplayDevice based on display name - /// - public DisplayDevice DisplayDevice - { - get => new DisplayDevice(Name); - } - - /// - /// Gets display driver build title - /// - public string DriverBuildTitle - { - get => DisplayApi.GetDisplayDriverBuildTitle(Handle); - } - - /// - /// Gets display handle - /// - public DisplayHandle Handle { get; } - - /// - /// Gets the display HDMI support information - /// - public IHDMISupportInfo HDMISupportInfo - { - get - { - var outputId = OutputId.Invalid; - try - { - outputId = DisplayApi.GetAssociatedDisplayOutputId(Handle); - } - catch (NVIDIAApiException) - { - // ignore - } - return DisplayApi.GetHDMISupportInfo(Handle, outputId); - } - } - - /// - /// Gets the corresponding HUE information - /// - public HUEInformation HUEControl - { - get => new HUEInformation(Handle); - } - - /// - /// Gets the driving logical GPU - /// - public LogicalGPU LogicalGPU - { - get => new LogicalGPU(GPUApi.GetLogicalGPUFromDisplay(Handle)); - } - - /// - /// Gets display name - /// - public string Name - { - get => DisplayApi.GetAssociatedNvidiaDisplayName(Handle); - } - - /// - /// Gets the connected GPU output - /// - public GPUOutput Output - { - get => new GPUOutput(DisplayApi.GetAssociatedDisplayOutputId(Handle), PhysicalGPUs.FirstOrDefault()); - } - - /// - /// Gets the list of all physical GPUs responsible for this display, with the first GPU returned as the one with the - /// attached active output. - /// - public PhysicalGPU[] PhysicalGPUs - { - get => GPUApi.GetPhysicalGPUsFromDisplay(Handle).Select(handle => new PhysicalGPU(handle)).ToArray(); - } - - /// - public bool Equals(Display other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Handle.Equals(other.Handle); - } - - /// - /// This function returns all NVIDIA displays - /// Note: Display handles can get invalidated on a modeset. - /// - /// An array of Display objects - public static Display[] GetDisplays() - { - return DisplayApi.EnumNvidiaDisplayHandle().Select(handle => new Display(handle)).ToArray(); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(Display left, Display right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(Display left, Display right) - { - return !(right == left); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((Display) obj); - } - - /// - public override int GetHashCode() - { - return Handle.GetHashCode(); - } - - /// - public override string ToString() - { - return Name; - } - - /// - /// Gets all the supported NVIDIA display views (nView and Dualview modes) for this display. - /// - /// - public TargetViewMode[] GetSupportedViews() - { - return DisplayApi.GetSupportedViews(Handle); - } - - /// - /// Overrides the refresh rate on this display. - /// The new refresh rate can be applied right away or deferred to be applied with the next OS - /// mode-set. - /// The override is good for only one mode-set (regardless whether it's deferred or immediate). - /// - /// The refresh rate to be applied. - /// - /// A boolean value indicating if the refresh rate override should be deferred to the next OS - /// mode-set. - /// - public void OverrideRefreshRate(float refreshRate, bool isDeferred = false) - { - DisplayApi.SetRefreshRateOverride(Handle, refreshRate, isDeferred); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/DisplayDevice.cs b/app/NvAPIWrapper/Display/DisplayDevice.cs deleted file mode 100644 index 5d404bf9..00000000 --- a/app/NvAPIWrapper/Display/DisplayDevice.cs +++ /dev/null @@ -1,893 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.GPU; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Interfaces.Display; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents an NVIDIA display device - /// - public class DisplayDevice : IEquatable - { - /// - /// Creates a new DisplayDevice - /// - /// Display identification of the device - public DisplayDevice(uint displayId) - { - DisplayId = displayId; - var extraInformation = PhysicalGPU.GetDisplayDevices().FirstOrDefault(ids => ids.DisplayId == DisplayId); - - if (extraInformation != null) - { - IsAvailable = true; - ScanOutInformation = new ScanOutInformation(this); - ConnectionType = extraInformation.ConnectionType; - IsDynamic = extraInformation.IsDynamic; - IsMultiStreamRootNode = extraInformation.IsMultiStreamRootNode; - IsActive = extraInformation.IsActive; - IsCluster = extraInformation.IsCluster; - IsOSVisible = extraInformation.IsOSVisible; - IsWFD = extraInformation.IsWFD; - IsConnected = extraInformation.IsConnected; - IsPhysicallyConnected = extraInformation.IsPhysicallyConnected; - } - } - - /// - /// Creates a new DisplayDevice - /// - /// Display identification and attributes of the display device - public DisplayDevice(IDisplayIds displayIds) - { - IsAvailable = true; - DisplayId = displayIds.DisplayId; - ScanOutInformation = new ScanOutInformation(this); - ConnectionType = displayIds.ConnectionType; - IsDynamic = displayIds.IsDynamic; - IsMultiStreamRootNode = displayIds.IsMultiStreamRootNode; - IsActive = displayIds.IsActive; - IsCluster = displayIds.IsCluster; - IsOSVisible = displayIds.IsOSVisible; - IsWFD = displayIds.IsWFD; - IsConnected = displayIds.IsConnected; - IsPhysicallyConnected = displayIds.IsPhysicallyConnected; - } - - /// - /// Creates a new DisplayDevice - /// - /// Display name of the display device - public DisplayDevice(string displayName) : this(DisplayApi.GetDisplayIdByDisplayName(displayName)) - { - } - - /// - /// Gets the display device connection type - /// - public MonitorConnectionType ConnectionType { get; } - - /// - /// Gets the current display color data - /// - public ColorData CurrentColorData - { - get - { - var instances = new IColorData[] - { - new ColorDataV5(ColorDataCommand.Get), - new ColorDataV4(ColorDataCommand.Get), - new ColorDataV3(ColorDataCommand.Get), - new ColorDataV2(ColorDataCommand.Get), - new ColorDataV1(ColorDataCommand.Get) - }; - - var instance = DisplayApi.ColorControl(DisplayId, instances); - - return new ColorData(instance); - } - } - - /// - /// Gets the current display device timing - /// - public Timing CurrentTiming - { - get => DisplayApi.GetTiming(DisplayId, new TimingInput(TimingOverride.Current)); - } - - /// - /// Gets the default display color data - /// - public ColorData DefaultColorData - { - get - { - var instances = new IColorData[] - { - new ColorDataV5(ColorDataCommand.GetDefault), - new ColorDataV4(ColorDataCommand.GetDefault), - new ColorDataV3(ColorDataCommand.GetDefault), - new ColorDataV2(ColorDataCommand.GetDefault), - new ColorDataV1(ColorDataCommand.GetDefault) - }; - - var instance = DisplayApi.ColorControl(DisplayId, instances); - - return new ColorData(instance); - } - } - - /// - /// Gets the NVIDIA display identification - /// - public uint DisplayId { get; } - - /// - /// Gets the monitor Display port capabilities - /// - public MonitorColorData[] DisplayPortColorCapabilities - { - get - { - if (ConnectionType != MonitorConnectionType.DisplayPort) - { - return null; - } - - return DisplayApi.GetMonitorColorCapabilities(DisplayId); - } - } - - /// - /// Gets the display driver EDID specified HDR capabilities - /// - public HDRCapabilitiesV1 DriverHDRCapabilities - { - get => DisplayApi.GetHDRCapabilities(DisplayId, true); - } - - /// - /// Gets the display currently effective HDR capabilities - /// - public HDRCapabilitiesV1 EffectiveHDRCapabilities - { - get => DisplayApi.GetHDRCapabilities(DisplayId, false); - } - - /// - /// Gets the HDMI audio info-frame current information - /// - public InfoFrameAudio? HDMIAudioFrameCurrentInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.Get, InfoFrameDataType.AudioInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AudioInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - - /// - /// Gets the HDMI audio info-frame default information - /// - public InfoFrameAudio? HDMIAudioFrameDefaultInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetDefault, InfoFrameDataType.AudioInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AudioInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDMI audio info-frame override information - /// - public InfoFrameAudio? HDMIAudioFrameOverrideInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetOverride, InfoFrameDataType.AudioInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AudioInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDMI audio info-frame property information - /// - public InfoFrameProperty? HDMIAudioFramePropertyInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetProperty, InfoFrameDataType.AudioInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.PropertyInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the device HDMI support information - /// - public IHDMISupportInfo HDMISupportInfo - { - get => DisplayApi.GetHDMISupportInfo(DisplayId); - } - - - /// - /// Gets the HDMI auxiliary video info-frame current information - /// - public InfoFrameVideo? HDMIVideoFrameCurrentInformation - { - get - { - try - { - var infoFrame = - new InfoFrameData(InfoFrameCommand.Get, InfoFrameDataType.AuxiliaryVideoInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AuxiliaryVideoInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDMI auxiliary video info-frame default information - /// - public InfoFrameVideo? HDMIVideoFrameDefaultInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetDefault, - InfoFrameDataType.AuxiliaryVideoInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AuxiliaryVideoInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDMI auxiliary video info-frame override information - /// - public InfoFrameVideo? HDMIVideoFrameOverrideInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetOverride, - InfoFrameDataType.AuxiliaryVideoInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.AuxiliaryVideoInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDMI auxiliary video info-frame property information - /// - public InfoFrameProperty? HDMIVideoFramePropertyInformation - { - get - { - try - { - var infoFrame = new InfoFrameData(InfoFrameCommand.GetProperty, - InfoFrameDataType.AuxiliaryVideoInformation); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - - return infoFrame.PropertyInformation; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Gets the HDR color data, or null if the HDR is disabled or unavailable - /// - public HDRColorData HDRColorData - { - get - { - try - { - var instances = new IHDRColorData[] - { - new HDRColorDataV2(ColorDataHDRCommand.Get), - new HDRColorDataV1(ColorDataHDRCommand.Get) - }; - - var instance = DisplayApi.HDRColorControl(DisplayId, instances); - - if (instance.HDRMode == ColorDataHDRMode.Off) - { - return null; - } - - return new HDRColorData(instance); - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return null; - } - - throw; - } - } - } - - /// - /// Indicates if the display is being actively driven - /// - public bool IsActive { get; } - - /// - /// Indicates if the display device is currently available - /// - public bool IsAvailable { get; } - - /// - /// Indicates if the display is the representative display - /// - public bool IsCluster { get; } - - /// - /// Indicates if the display is connected - /// - public bool IsConnected { get; } - - /// - /// Indicates if the display is part of MST topology and it's a dynamic - /// - public bool IsDynamic { get; } - - /// - /// Indicates if the display identification belongs to a multi stream enabled connector (root node). Note that when - /// multi stream is enabled and a single multi stream capable monitor is connected to it, the monitor will share the - /// display id with the RootNode. - /// When there is more than one monitor connected in a multi stream topology, then the root node will have a separate - /// displayId. - /// - public bool IsMultiStreamRootNode { get; } - - /// - /// Indicates if the display is reported to the OS - /// - public bool IsOSVisible { get; } - - /// - /// Indicates if the display is a physically connected display; Valid only when IsConnected is true - /// - public bool IsPhysicallyConnected { get; } - - /// - /// Indicates if the display is wireless - /// - public bool IsWFD { get; } - - /// - /// Gets the connected GPU output - /// - public GPUOutput Output - { - get - { - PhysicalGPUHandle handle; - var outputId = GPUApi.GetGPUAndOutputIdFromDisplayId(DisplayId, out handle); - - return new GPUOutput(outputId, new PhysicalGPU(handle)); - } - } - - /// - /// Gets the connected physical GPU - /// - public PhysicalGPU PhysicalGPU - { - get - { - try - { - var gpuHandle = GPUApi.GetPhysicalGPUFromDisplayId(DisplayId); - - return new PhysicalGPU(gpuHandle); - } - catch - { - // ignored - } - - return Output.PhysicalGPU; - } - } - - /// - /// Gets information regarding the scan-out settings of this display device - /// - public ScanOutInformation ScanOutInformation { get; } - - /// - /// Gets monitor capabilities from the Video Capability Data Block if available, otherwise null - /// - public MonitorVCDBCapabilities? VCDBMonitorCapabilities - { - get => DisplayApi.GetMonitorCapabilities(DisplayId, MonitorCapabilitiesType.VCDB)?.VCDBCapabilities; - } - - /// - /// Gets monitor capabilities from the Vendor Specific Data Block if available, otherwise null - /// - public MonitorVSDBCapabilities? VSDBMonitorCapabilities - { - get => DisplayApi.GetMonitorCapabilities(DisplayId, MonitorCapabilitiesType.VSDB)?.VSDBCapabilities; - } - - /// - public bool Equals(DisplayDevice other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return DisplayId == other.DisplayId; - } - - /// - /// Deletes a custom resolution. - /// - /// The custom resolution to delete. - /// A list of display ids to remove the custom resolution from. - public static void DeleteCustomResolution(CustomResolution customResolution, uint[] displayIds) - { - var customDisplay = customResolution.AsCustomDisplay(false); - DisplayApi.DeleteCustomDisplay(displayIds, customDisplay); - } - - /// - /// Returns an instance of representing the primary GDI display device. - /// - /// An instance of . - public static DisplayDevice GetGDIPrimaryDisplayDevice() - { - var displayId = DisplayApi.GetGDIPrimaryDisplayId(); - - if (displayId == 0) - { - return null; - } - - return new DisplayDevice(displayId); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DisplayDevice left, DisplayDevice right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DisplayDevice left, DisplayDevice right) - { - return !(right == left); - } - - /// - /// Reverts the custom resolution currently on trial. - /// - /// A list of display ids to revert the custom resolution from. - public static void RevertCustomResolution(uint[] displayIds) - { - DisplayApi.RevertCustomDisplayTrial(displayIds); - } - - /// - /// Saves the custom resolution currently on trial. - /// - /// A list of display ids to save the custom resolution for. - /// - /// If set, the saved custom display will only be applied on the monitor with the same - /// outputId. - /// - /// - /// If set, the saved custom display will only be applied on the monitor with the same EDID - /// ID or the same TV connector in case of analog TV. - /// - public static void SaveCustomResolution(uint[] displayIds, bool isThisOutputIdOnly, bool isThisMonitorOnly) - { - DisplayApi.SaveCustomDisplay(displayIds, isThisOutputIdOnly, isThisMonitorOnly); - } - - /// - /// Applies a custom resolution into trial - /// - /// The custom resolution to apply. - /// A list of display ids to apply the custom resolution on. - /// - /// A boolean value indicating that a hardware mode-set without OS update should be - /// performed. - /// - public static void TrialCustomResolution( - CustomResolution customResolution, - uint[] displayIds, - bool hardwareModeSetOnly = true) - { - var customDisplay = customResolution.AsCustomDisplay(hardwareModeSetOnly); - DisplayApi.TryCustomDisplay(displayIds.ToDictionary(u => u, u => customDisplay)); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((DisplayDevice) obj); - } - - /// - public override int GetHashCode() - { - return (int) DisplayId; - } - - - /// - public override string ToString() - { - return $"Display #{DisplayId}"; - } - - /// - /// Calculates a valid timing based on the argument passed - /// - /// The preferred width. - /// The preferred height. - /// The preferred refresh rate. - /// The boolean value indicating if the preferred resolution is an interlaced resolution. - /// Returns a valid instance of . - public Timing CalculateTiming(uint width, uint height, float refreshRate, bool isInterlaced) - { - return DisplayApi.GetTiming( - DisplayId, - new TimingInput(width, height, refreshRate, TimingOverride.Auto, isInterlaced) - ); - } - - /// - /// Deletes a custom resolution. - /// - /// The custom resolution to delete. - public void DeleteCustomResolution(CustomResolution customResolution) - { - DeleteCustomResolution(customResolution, new[] {DisplayId}); - } - - /// - /// Retrieves the list of custom resolutions saved for this display device - /// - /// A list of instances. - public IEnumerable GetCustomResolutions() - { - return DisplayApi.EnumCustomDisplays(DisplayId).Select(custom => new CustomResolution(custom)); - } - - /// - /// Checks if a color data is supported on this display - /// - /// The color data to be checked. - /// true if the color data passed is supported; otherwise false - public bool IsColorDataSupported(ColorData colorData) - { - var instances = new IColorData[] - { - colorData.AsColorDataV5(ColorDataCommand.IsSupportedColor), - colorData.AsColorDataV4(ColorDataCommand.IsSupportedColor), - colorData.AsColorDataV3(ColorDataCommand.IsSupportedColor), - colorData.AsColorDataV2(ColorDataCommand.IsSupportedColor), - colorData.AsColorDataV1(ColorDataCommand.IsSupportedColor) - }; - - try - { - DisplayApi.ColorControl(DisplayId, instances); - - return true; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.NotSupported) - { - return false; - } - - throw; - } - } - - /// - /// Resets the HDMI audio info-frame information to default - /// - public void ResetHDMIAudioFrameInformation() - { - var infoFrame = new InfoFrameData( - InfoFrameCommand.Reset, - InfoFrameDataType.AudioInformation - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Resets the HDMI auxiliary video info-frame information to default - /// - public void ResetHDMIVideoFrameInformation() - { - var infoFrame = new InfoFrameData( - InfoFrameCommand.Reset, - InfoFrameDataType.AuxiliaryVideoInformation - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Reverts the custom resolution currently on trial. - /// - public void RevertCustomResolution() - { - RevertCustomResolution(new[] {DisplayId}); - } - - /// - /// Saves the custom resolution currently on trial. - /// - /// - /// If set, the saved custom display will only be applied on the monitor with the same - /// outputId. - /// - /// - /// If set, the saved custom display will only be applied on the monitor with the same EDID - /// ID or the same TV connector in case of analog TV. - /// - public void SaveCustomResolution(bool isThisOutputIdOnly = true, bool isThisMonitorOnly = true) - { - SaveCustomResolution(new[] {DisplayId}, isThisOutputIdOnly, isThisMonitorOnly); - } - - /// - /// Changes the display current color data configuration - /// - /// The color data to be set. - public void SetColorData(ColorData colorData) - { - var instances = new IColorData[] - { - colorData.AsColorDataV5(ColorDataCommand.Set), - colorData.AsColorDataV4(ColorDataCommand.Set), - colorData.AsColorDataV3(ColorDataCommand.Set), - colorData.AsColorDataV2(ColorDataCommand.Set), - colorData.AsColorDataV1(ColorDataCommand.Set) - }; - - DisplayApi.ColorControl(DisplayId, instances); - } - - /// - /// Sets the HDMI video info-frame current or override information - /// - /// The new information. - /// A boolean value indicating if the changes should persist mode-set and OS restart. - public void SetHDMIAudioFrameInformation(InfoFrameAudio audio, bool isOverride = false) - { - var infoFrame = new InfoFrameData( - isOverride ? InfoFrameCommand.SetOverride : InfoFrameCommand.Set, - audio - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Sets the HDMI audio info-frame property information - /// - /// The new property information. - public void SetHDMIAudioFramePropertyInformation(InfoFrameProperty property) - { - var infoFrame = new InfoFrameData( - InfoFrameCommand.SetProperty, - InfoFrameDataType.AudioInformation, - property - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Sets the HDMI auxiliary video info-frame current or override information - /// - /// The new information. - /// A boolean value indicating if the changes should persist mode-set and OS restart. - public void SetHDMIVideoFrameInformation(InfoFrameVideo video, bool isOverride = false) - { - var infoFrame = new InfoFrameData( - isOverride ? InfoFrameCommand.SetOverride : InfoFrameCommand.Set, - video - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Sets the HDMI auxiliary video info-frame property information - /// - /// The new property information. - public void SetHDMIVideoFramePropertyInformation(InfoFrameProperty property) - { - var infoFrame = new InfoFrameData( - InfoFrameCommand.SetProperty, - InfoFrameDataType.AuxiliaryVideoInformation, - property - ); - DisplayApi.InfoFrameControl(DisplayId, ref infoFrame); - } - - /// - /// Changes the display HDR color data configuration - /// - /// The color data to be set. - public void SetHDRColorData(HDRColorData colorData) - { - var instances = new IHDRColorData[] - { - colorData.AsHDRColorDataV2(ColorDataHDRCommand.Set), - colorData.AsHDRColorDataV1(ColorDataHDRCommand.Set) - }; - - DisplayApi.HDRColorControl(DisplayId, instances); - } - - /// - /// Applies a custom resolution into trial. - /// - /// The custom resolution to apply. - /// - /// A boolean value indicating that a hardware mode-set without OS update should be - /// performed. - /// - public void TrialCustomResolution(CustomResolution customResolution, bool hardwareModeSetOnly = true) - { - TrialCustomResolution(customResolution, new[] {DisplayId}, hardwareModeSetOnly); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/FloatTexture.cs b/app/NvAPIWrapper/Display/FloatTexture.cs deleted file mode 100644 index 74ee5524..00000000 --- a/app/NvAPIWrapper/Display/FloatTexture.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Linq; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a texture of float values - /// - public class FloatTexture : IEquatable - { - /// - /// Underlying float array containing the values of all channels in all pixels - /// - protected readonly float[] UnderlyingArray; - - /// - /// Creates a new instance of . - /// - /// The texture width. - /// The texture height. - /// The number of texture channels. - public FloatTexture(int width, int height, int channels) : this(width, height, channels, null) - { - } - - /// - /// Creates a new instance of . - /// - /// The texture width. - /// The texture height. - /// The number of texture channels. - /// The underlying array containing all float values. - // ReSharper disable once TooManyDependencies - protected FloatTexture(int width, int height, int channels, float[] array) - { - Width = width; - Height = height; - Channels = channels; - UnderlyingArray = array ?? new float[width * height * channels]; - } - - /// - /// Gets the number of texture channels - /// - public int Channels { get; } - - /// - /// Gets the texture height in pixel - /// - public int Height { get; } - - /// - /// Gets the texture width in pixels - /// - public int Width { get; } - - /// - public bool Equals(FloatTexture other) - { - if (other == null) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - if (other.UnderlyingArray.Length != UnderlyingArray.Length) - { - return false; - } - - if (other.Width != Width || other.Height != Height || other.Channels != Channels) - { - return false; - } - - return !UnderlyingArray.Where((t, i) => Math.Abs(other.UnderlyingArray[i] - t) > 0.0001).Any(); - } - - /// - /// Returns a new instance of FloatTexture from the passed array of float values. - /// - /// The texture width. - /// The texture height. - /// The texture channels. - /// The array of float values. - /// A new instance of . - // ReSharper disable once TooManyArguments - public static FloatTexture FromFloatArray(int width, int height, int channels, float[] floats) - { - if (floats.Length != width * height * channels) - { - throw new ArgumentOutOfRangeException(nameof(floats)); - } - - return new FloatTexture(width, height, channels, floats.ToArray()); - } - - /// - /// Compares two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are equal, otherwise - public static bool operator ==(FloatTexture left, FloatTexture right) - { - return Equals(left, right) || left?.Equals(right) == true; - } - - /// - /// Compares two instance of for in-equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are not equal, otherwise - public static bool operator !=(FloatTexture left, FloatTexture right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return Equals(obj as FloatTexture); - } - - /// - public override int GetHashCode() - { - return UnderlyingArray.GetHashCode(); - } - - /// - /// Gets the values of each channel at a specific location - /// - /// The horizontal location. - /// The vertical location. - /// An array of float values each representing a channel value. - public float[] GetValues(int x, int y) - { - return UnderlyingArray.Skip(y * Width + x).Take(Channels).ToArray(); - } - - /// - /// Sets the value of each channel at a specific location - /// - /// The horizontal location. - /// The vertical location. - /// An array of float values each representing a channel value. - public void SetValues(int x, int y, params float[] floats) - { - var index = y * Width + x; - - for (var i = 0; i < Math.Min(Channels, floats.Length); i++) - { - UnderlyingArray[index + i] = floats[i]; - } - } - - /// - /// Returns this instance of as an array of float values. - /// - /// An array of float values representing this instance of . - public float[] ToFloatArray() - { - // Returns a copy of the underlying array - return UnderlyingArray.ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/HDRColorData.cs b/app/NvAPIWrapper/Display/HDRColorData.cs deleted file mode 100644 index 935c2601..00000000 --- a/app/NvAPIWrapper/Display/HDRColorData.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - public class HDRColorData : IHDRColorData, IEquatable - { - /// - /// Creates an instance of . - /// - /// The hdr mode. - /// The display color space configurations. - /// The color data color format. - /// The color data dynamic range. - /// The color data color depth. - public HDRColorData( - ColorDataHDRMode hdrMode, - MasteringDisplayColorData masteringDisplayData, - ColorDataFormat? colorFormat = null, - ColorDataDynamicRange? dynamicRange = null, - ColorDataDepth? colorDepth = null - ) - { - HDRMode = hdrMode; - MasteringDisplayData = masteringDisplayData; - ColorFormat = colorFormat; - DynamicRange = dynamicRange; - ColorDepth = colorDepth; - } - - internal HDRColorData(IHDRColorData colorData) - { - HDRMode = colorData.HDRMode; - MasteringDisplayData = colorData.MasteringDisplayData; - ColorDepth = colorData.ColorDepth; - ColorFormat = colorData.ColorFormat; - DynamicRange = colorData.DynamicRange; - } - - /// - public bool Equals(HDRColorData other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return ColorDepth == other.ColorDepth && - ColorFormat == other.ColorFormat && - DynamicRange == other.DynamicRange && - HDRMode == other.HDRMode && - MasteringDisplayData.Equals(other.MasteringDisplayData); - } - - /// - public ColorDataDepth? ColorDepth { get; } - - /// - public ColorDataFormat? ColorFormat { get; } - - /// - public ColorDataDynamicRange? DynamicRange { get; } - - /// - public ColorDataHDRMode HDRMode { get; } - - /// - public MasteringDisplayColorData MasteringDisplayData { get; } - - /// - /// Compares two instances of for equality. - /// - /// The first instance. - /// The second instance. - /// true if two instances are equal; otherwise false. - public static bool operator ==(HDRColorData left, HDRColorData right) - { - return left?.Equals(right) == true; - } - - /// - /// Compares two instances of for inequality. - /// - /// The first instance. - /// The second instance. - /// true if two instances are not equal; otherwise false. - public static bool operator !=(HDRColorData left, HDRColorData right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((HDRColorData) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = ColorDepth.GetHashCode(); - hashCode = (hashCode * 397) ^ ColorFormat.GetHashCode(); - hashCode = (hashCode * 397) ^ DynamicRange.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) HDRMode; - hashCode = (hashCode * 397) ^ MasteringDisplayData.GetHashCode(); - - return hashCode; - } - } - - internal HDRColorDataV1 AsHDRColorDataV1(ColorDataHDRCommand command) - { - return new HDRColorDataV1( - command, - HDRMode, - MasteringDisplayData - ); - } - - internal HDRColorDataV2 AsHDRColorDataV2(ColorDataHDRCommand command) - { - return new HDRColorDataV2( - command, - HDRMode, - MasteringDisplayData, - ColorFormat ?? ColorDataFormat.Auto, - DynamicRange ?? ColorDataDynamicRange.Auto, - ColorDepth ?? ColorDataDepth.Default - ); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/HUEInformation.cs b/app/NvAPIWrapper/Display/HUEInformation.cs deleted file mode 100644 index 22ef2d7b..00000000 --- a/app/NvAPIWrapper/Display/HUEInformation.cs +++ /dev/null @@ -1,97 +0,0 @@ -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Display -{ - /// - /// This class contains and provides a way to modify the HUE angle - /// - public class HUEInformation - { - private readonly DisplayHandle _displayHandle = DisplayHandle.DefaultHandle; - private readonly OutputId _outputId = OutputId.Invalid; - - /// - /// Creates a new instance of the class using a DisplayHandle - /// - /// The handle of the display. - public HUEInformation(DisplayHandle displayHandle) - { - _displayHandle = displayHandle; - } - - /// - /// Creates a new instance of this class using a OutputId - /// - /// The output identification of a display or an output - public HUEInformation(OutputId outputId) - { - _outputId = outputId; - } - - /// - /// Gets or sets the current HUE offset angle [0-359] - /// - public int CurrentAngle - { - get - { - PrivateDisplayHUEInfo? hueInfo = null; - - if (_displayHandle != DisplayHandle.DefaultHandle) - { - hueInfo = DisplayApi.GetHUEInfo(_displayHandle); - } - else if (_outputId != OutputId.Invalid) - { - hueInfo = DisplayApi.GetHUEInfo(_outputId); - } - - return hueInfo?.CurrentAngle ?? 0; - } - set - { - value %= 360; - - if (_displayHandle != DisplayHandle.DefaultHandle) - { - DisplayApi.SetHUEAngle(_displayHandle, value); - } - else if (_outputId != OutputId.Invalid) - { - DisplayApi.SetHUEAngle(_outputId, value); - } - } - } - - /// - /// Gets the default HUE offset angle [0-359] - /// - public int DefaultAngle - { - get - { - PrivateDisplayHUEInfo? hueInfo = null; - - if (_displayHandle != DisplayHandle.DefaultHandle) - { - hueInfo = DisplayApi.GetHUEInfo(_displayHandle); - } - else if (_outputId != OutputId.Invalid) - { - hueInfo = DisplayApi.GetHUEInfo(_outputId); - } - - return hueInfo?.DefaultAngle ?? 0; - } - } - - - /// - public override string ToString() - { - return $"{CurrentAngle:D}º [{DefaultAngle:D}º]"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/IntensityTexture.cs b/app/NvAPIWrapper/Display/IntensityTexture.cs deleted file mode 100644 index 0025f3c6..00000000 --- a/app/NvAPIWrapper/Display/IntensityTexture.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Linq; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a texture of intensity values - /// - public class IntensityTexture : FloatTexture - { - /// - /// Creates a new instance of . - /// - /// The texture width. - /// The texture height. - public IntensityTexture(int width, int height) : base(width, height, 3) - { - } - - private IntensityTexture(int width, int height, float[] floats) : base(width, height, 3, floats) - { - } - - /// - /// Returns a new instance of FloatTexture from the passed array of float values. - /// - /// The texture width. - /// The texture height. - /// The array of float values. - /// A new instance of . - // ReSharper disable once TooManyArguments - public static IntensityTexture FromFloatArray(int width, int height, float[] floats) - { - if (floats.Length != width * height * 3) - { - throw new ArgumentOutOfRangeException(nameof(floats)); - } - - return new IntensityTexture(width, height, floats.ToArray()); - } - - /// - /// Gets the value of intensity pixel at a specific location. - /// - /// The horizontal location. - /// The vertical location. - /// An instance of . - public IntensityTexturePixel GetPixel(int x, int y) - { - return IntensityTexturePixel.FromFloatArray(UnderlyingArray, y * Width + x); - } - - /// - /// Sets the value of intensity pixel at a specific location - /// - /// The horizontal location. - /// The vertical location. - /// An instance of . - public void SetPixel(int x, int y, IntensityTexturePixel pixel) - { - var index = y * Width + x; - var floats = pixel.ToFloatArray(); - - for (var i = 0; i < Math.Min(Channels, floats.Length); i++) - { - UnderlyingArray[index + i] = floats[i]; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/IntensityTexturePixel.cs b/app/NvAPIWrapper/Display/IntensityTexturePixel.cs deleted file mode 100644 index b357773b..00000000 --- a/app/NvAPIWrapper/Display/IntensityTexturePixel.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a RGB intensity texture pixel - /// - public class IntensityTexturePixel : IEquatable - { - /// - /// Creates a new instance of . - /// - /// The intensity of the red light (0-1) - /// The intensity of the green light (0-1) - /// The intensity of the blue light (0-1) - public IntensityTexturePixel(float redIntensity, float greenIntensity, float blueIntensity) - { - RedIntensity = Math.Max(Math.Min(redIntensity, 1), 0); - GreenIntensity = Math.Max(Math.Min(greenIntensity, 1), 0); - BlueIntensity = Math.Max(Math.Min(blueIntensity, 1), 0); - } - - /// - /// Gets the intensity of the blue light (0-1) - /// - public float BlueIntensity { get; } - - /// - /// Gets the intensity of the green light (0-1) - /// - public float GreenIntensity { get; } - - /// - /// Gets the intensity of the red light (0-1) - /// - public float RedIntensity { get; } - - /// - public bool Equals(IntensityTexturePixel other) - { - if (other == null) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Math.Abs(RedIntensity - other.RedIntensity) < 0.0001 && - Math.Abs(GreenIntensity - other.GreenIntensity) < 0.0001 && - Math.Abs(BlueIntensity - other.BlueIntensity) < 0.0001; - } - - /// - /// Compares two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are equal, otherwise - public static bool operator ==(IntensityTexturePixel left, IntensityTexturePixel right) - { - return Equals(left, right) || left?.Equals(right) == true; - } - - /// - /// Compares two instance of for in-equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are not equal, otherwise - public static bool operator !=(IntensityTexturePixel left, IntensityTexturePixel right) - { - return !(left == right); - } - - internal static IntensityTexturePixel FromFloatArray(float[] floats, int index) - { - return new IntensityTexturePixel(floats[index], floats[index + 1], floats[index + 2]); - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return Equals(obj as IntensityTexturePixel); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = RedIntensity.GetHashCode(); - hashCode = (hashCode * 397) ^ GreenIntensity.GetHashCode(); - hashCode = (hashCode * 397) ^ BlueIntensity.GetHashCode(); - - return hashCode; - } - } - - internal float[] ToFloatArray() - { - return new[] {RedIntensity, GreenIntensity, BlueIntensity}; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/PathInfo.cs b/app/NvAPIWrapper/Display/PathInfo.cs deleted file mode 100644 index 02551a1e..00000000 --- a/app/NvAPIWrapper/Display/PathInfo.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a configuration path - /// - public class PathInfo : IEquatable - { - /// - /// Creates a new PathInfo - /// - /// Display resolution - /// Display color format - /// Target configuration informations - public PathInfo(Resolution resolution, ColorFormat colorFormat, PathTargetInfo[] targetInfos) - { - Resolution = resolution; - ColorFormat = colorFormat; - TargetsInfo = targetInfos; - } - - /// - /// Creates a new PathInfo - /// - /// IPathInfo implamented object - public PathInfo(IPathInfo info) - { - SourceId = info.SourceId; - Resolution = info.SourceModeInfo.Resolution; - ColorFormat = info.SourceModeInfo.ColorFormat; - Position = info.SourceModeInfo.Position; - SpanningOrientation = info.SourceModeInfo.SpanningOrientation; - IsGDIPrimary = info.SourceModeInfo.IsGDIPrimary; - IsSLIFocus = info.SourceModeInfo.IsSLIFocus; - TargetsInfo = - info.TargetsInfo.Select(targetInfo => new PathTargetInfo(targetInfo)).ToArray(); - - if (info is PathInfoV2) - { - OSAdapterLUID = ((PathInfoV2) info).OSAdapterLUID; - } - } - - /// - /// Gets or sets the display color format - /// - public ColorFormat ColorFormat { get; set; } - - /// - /// Gets or sets a boolean value indicating if the this is the primary GDI display - /// - public bool IsGDIPrimary { get; set; } - - /// - /// Gets or sets a boolean value indicating if the this is the SLI focus display - /// - public bool IsSLIFocus { get; set; } - - /// - /// Gets OS Adapter of LUID for Non-NVIDIA adapters - /// - public LUID? OSAdapterLUID { get; } - - /// - /// Gets or sets the display position - /// - public Position Position { get; set; } - - /// - /// Gets or sets the display resolution - /// - public Resolution Resolution { get; set; } - - /// - /// Gets or sets the Windows CCD display source identification. This can be optionally set. - /// - public uint SourceId { get; set; } - - /// - /// Gets or sets the display spanning orientation, valid for XP only - /// - public SpanningOrientation SpanningOrientation { get; set; } - - - /// - /// Gets information about path targets - /// - public PathTargetInfo[] TargetsInfo { get; } - - - /// - /// Checks for equality with a PathInfo instance - /// - /// The PathInfo object to check with - /// true if both objects are equal, otherwise false - public bool Equals(PathInfo other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Resolution.Equals(other.Resolution) && - ColorFormat == other.ColorFormat && - Position.Equals(other.Position) && - SpanningOrientation == other.SpanningOrientation && - IsGDIPrimary == other.IsGDIPrimary && - IsSLIFocus == other.IsSLIFocus && - TargetsInfo.SequenceEqual(other.TargetsInfo); - } - - - /// - /// Creates and fills a PathInfo object - /// - /// The newly created PathInfo object - public static PathInfo[] GetDisplaysConfig() - { - var configs = DisplayApi.GetDisplayConfig(); - var logicalDisplays = configs.Select(info => new PathInfo(info)).ToArray(); - configs.DisposeAll(); - - return logicalDisplays; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(PathInfo left, PathInfo right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(PathInfo left, PathInfo right) - { - return !(left == right); - } - - /// - /// Applies one or more path information configurations - /// - /// An array of path information configuration - /// DisplayConfigFlags flags - public static void SetDisplaysConfig(PathInfo[] pathInfos, DisplayConfigFlags flags) - { - try - { - var configsV2 = pathInfos.Select(config => config.GetPathInfoV2()).Cast().ToArray(); - DisplayApi.SetDisplayConfig(configsV2, flags); - configsV2.DisposeAll(); - } - catch (NVIDIAApiException ex) - { - if (ex.Status != Status.IncompatibleStructureVersion) - { - throw; - } - } - catch (NVIDIANotSupportedException) - { - // ignore - } - - var configsV1 = pathInfos.Select(config => config.GetPathInfoV1()).Cast().ToArray(); - DisplayApi.SetDisplayConfig(configsV1, flags); - configsV1.DisposeAll(); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((PathInfo) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = Resolution.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) ColorFormat; - hashCode = (hashCode * 397) ^ Position.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) SpanningOrientation; - hashCode = (hashCode * 397) ^ IsGDIPrimary.GetHashCode(); - hashCode = (hashCode * 397) ^ IsSLIFocus.GetHashCode(); - hashCode = (hashCode * 397) ^ (TargetsInfo?.GetHashCode() ?? 0); - - return hashCode; - } - } - - - /// - public override string ToString() - { - return $"{Resolution} @ {Position} [{TargetsInfo.Length}]"; - } - - /// - /// Creates and fills a GetPathInfoV1 object - /// - /// The newly created GetPathInfoV1 object - public PathInfoV1 GetPathInfoV1() - { - var sourceModeInfo = GetSourceModeInfo(); - var pathTargetInfoV1 = GetPathTargetInfoV1Array(); - - return new PathInfoV1(pathTargetInfoV1, sourceModeInfo, SourceId); - } - - /// - /// Creates and fills a GetPathInfoV2 object - /// - /// The newly created GetPathInfoV2 object - public PathInfoV2 GetPathInfoV2() - { - var sourceModeInfo = GetSourceModeInfo(); - var pathTargetInfoV2 = GetPathTargetInfoV2Array(); - - return new PathInfoV2(pathTargetInfoV2, sourceModeInfo, SourceId); - } - - /// - /// Creates and fills an array of GetPathTargetInfoV1 object - /// - /// The newly created array of GetPathTargetInfoV1 objects - public PathTargetInfoV1[] GetPathTargetInfoV1Array() - { - return TargetsInfo.Select(config => config.GetPathTargetInfoV1()).ToArray(); - } - - /// - /// Creates and fills an array of GetPathTargetInfoV2 object - /// - /// The newly created array of GetPathTargetInfoV2 objects - public PathTargetInfoV2[] GetPathTargetInfoV2Array() - { - return TargetsInfo.Select(config => config.GetPathTargetInfoV2()).ToArray(); - } - - /// - /// Creates and fills a SourceModeInfo object - /// - /// The newly created SourceModeInfo object - public SourceModeInfo GetSourceModeInfo() - { - return new SourceModeInfo(Resolution, ColorFormat, Position, SpanningOrientation, IsGDIPrimary, IsSLIFocus); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/PathTargetInfo.cs b/app/NvAPIWrapper/Display/PathTargetInfo.cs deleted file mode 100644 index dde14d1d..00000000 --- a/app/NvAPIWrapper/Display/PathTargetInfo.cs +++ /dev/null @@ -1,304 +0,0 @@ -using System; -using System.Collections.Generic; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a display configuration on a path - /// - public class PathTargetInfo : IEquatable - { - private TimingOverride _timingOverride; - - /// - /// Creates a new PathTargetInfo - /// - /// IPathTargetInfo implamented object - public PathTargetInfo(IPathTargetInfo info) - { - DisplayDevice = new DisplayDevice(info.DisplayId); - - if (info.Details.HasValue) - { - Rotation = info.Details.Value.Rotation; - Scaling = info.Details.Value.Scaling; - TVConnectorType = info.Details.Value.ConnectorType; - TVFormat = info.Details.Value.TVFormat; - RefreshRateInMillihertz = info.Details.Value.RefreshRateInMillihertz; - TimingOverride = info.Details.Value.TimingOverride; - IsInterlaced = info.Details.Value.IsInterlaced; - IsClonePrimary = info.Details.Value.IsClonePrimary; - IsClonePanAndScanTarget = info.Details.Value.IsClonePanAndScanTarget; - DisableVirtualModeSupport = info.Details.Value.DisableVirtualModeSupport; - IsPreferredUnscaledTarget = info.Details.Value.IsPreferredUnscaledTarget; - } - - if (info is PathTargetInfoV2) - { - WindowsCCDTargetId = ((PathTargetInfoV2) info).WindowsCCDTargetId; - } - } - - /// - /// Creates a new PathTargetInfo - /// - /// DisplayDevice object - public PathTargetInfo(DisplayDevice device) - { - DisplayDevice = device; - } - - /// - /// Gets or sets the virtual mode support - /// - public bool DisableVirtualModeSupport { get; set; } - - /// - /// Gets corresponding DisplayDevice - /// - public DisplayDevice DisplayDevice { get; } - - /// - /// Gets or sets the pan and scan is availability. Valid only when the target is part of clone - /// topology. - /// - public bool IsClonePanAndScanTarget { get; set; } - - /// - /// Gets or sets the primary display in clone configuration. This is *NOT* GDI Primary. - /// Only one target can be primary per source. If no primary is specified, the first target will automatically be - /// primary. - /// - public bool IsClonePrimary { get; set; } - - /// - /// Gets or sets the interlaced mode flag, ignored if refreshRate == 0 - /// - public bool IsInterlaced { get; set; } - - /// - /// Gets or sets the preferred unscaled mode of target - /// - public bool IsPreferredUnscaledTarget { get; set; } - - /// - /// Gets and sets the non-interlaced Refresh Rate of the mode, multiplied by 1000, 0 = ignored - /// This is the value which driver reports to the OS. - /// - public uint RefreshRateInMillihertz { get; set; } - - /// - /// Gets and sets the rotation setting - /// - public Rotate Rotation { get; set; } - - /// - /// Gets and sets the scaling setting - /// - public Scaling Scaling { get; set; } - - /// - /// Gets and sets the custom timing of display - /// Ignored if TimingOverride == TimingOverride.Current - /// - public TimingOverride TimingOverride - { - get => _timingOverride; - set - { - if (value == TimingOverride.Custom) - { - throw new NVIDIANotSupportedException("Custom timing is not supported yet."); - } - - _timingOverride = value; - } - } - - /// - /// Gets and sets the connector type. For TV only, ignored if TVFormat == TVFormat.None. - /// - public ConnectorType TVConnectorType { get; set; } - - /// - /// Gets and sets the TV format. For TV only, otherwise set to TVFormat.None - /// - public TVFormat TVFormat { get; set; } - - /// - /// Gets the Windows CCD target ID. Must be present only for non-NVIDIA adapter, for NVIDIA adapter this parameter is - /// ignored. - /// - public uint WindowsCCDTargetId { get; } - - /// - /// Checks for equality with a PathTargetInfo instance - /// - /// The PathTargetInfo object to check with - /// true if both objects are equal, otherwise false - public bool Equals(PathTargetInfo other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return _timingOverride == other._timingOverride && - Rotation == other.Rotation && - Scaling == other.Scaling && - RefreshRateInMillihertz == other.RefreshRateInMillihertz && - (TVFormat == TVFormat.None || TVConnectorType == other.TVConnectorType) && - TVFormat == other.TVFormat && - DisplayDevice.Equals(other.DisplayDevice) && - IsInterlaced == other.IsInterlaced && - IsClonePrimary == other.IsClonePrimary && - IsClonePanAndScanTarget == other.IsClonePanAndScanTarget && - DisableVirtualModeSupport == other.DisableVirtualModeSupport && - IsPreferredUnscaledTarget == other.IsPreferredUnscaledTarget; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(PathTargetInfo left, PathTargetInfo right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(PathTargetInfo left, PathTargetInfo right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((PathTargetInfo) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _timingOverride; - hashCode = (hashCode * 397) ^ (int) Rotation; - hashCode = (hashCode * 397) ^ (int) Scaling; - hashCode = (hashCode * 397) ^ (int) RefreshRateInMillihertz; - hashCode = (hashCode * 397) ^ (int) TVFormat; - hashCode = (hashCode * 397) ^ (TVFormat != TVFormat.None ? (int) TVConnectorType : 0); - hashCode = (hashCode * 397) ^ (DisplayDevice?.GetHashCode() ?? 0); - hashCode = (hashCode * 397) ^ IsInterlaced.GetHashCode(); - hashCode = (hashCode * 397) ^ IsClonePrimary.GetHashCode(); - hashCode = (hashCode * 397) ^ IsClonePanAndScanTarget.GetHashCode(); - hashCode = (hashCode * 397) ^ DisableVirtualModeSupport.GetHashCode(); - hashCode = (hashCode * 397) ^ IsPreferredUnscaledTarget.GetHashCode(); - - return hashCode; - } - } - - /// - public override string ToString() - { - var strs = new List - { - DisplayDevice.ToString() - }; - - if (RefreshRateInMillihertz > 0) - { - strs.Add($"@ {RefreshRateInMillihertz / 1000}hz"); - } - - if (TVFormat != TVFormat.None) - { - strs.Add($"- TV {TVFormat}"); - } - - strs.Add(IsInterlaced ? "Interlaced" : "Progressive"); - - if (Rotation != Rotate.Degree0) - { - strs.Add($"- Rotation: {Rotation}"); - } - - return string.Join(" ", strs); - } - - - /// - /// Creates and fills a PathAdvancedTargetInfo object - /// - /// The newly created PathAdvancedTargetInfo object - public PathAdvancedTargetInfo GetPathAdvancedTargetInfo() - { - if (TVFormat == TVFormat.None) - { - return new PathAdvancedTargetInfo(Rotation, Scaling, RefreshRateInMillihertz, TimingOverride, - IsInterlaced, IsClonePrimary, IsClonePanAndScanTarget, DisableVirtualModeSupport, - IsPreferredUnscaledTarget); - } - - return new PathAdvancedTargetInfo(Rotation, Scaling, TVFormat, TVConnectorType, RefreshRateInMillihertz, - TimingOverride, IsInterlaced, IsClonePrimary, IsClonePanAndScanTarget, DisableVirtualModeSupport, - IsPreferredUnscaledTarget); - } - - /// - /// Creates and fills a PathTargetInfoV1 object - /// - /// The newly created PathTargetInfoV1 object - public PathTargetInfoV1 GetPathTargetInfoV1() - { - var pathAdvancedTargetInfo = GetPathAdvancedTargetInfo(); - - return new PathTargetInfoV1(DisplayDevice.DisplayId, pathAdvancedTargetInfo); - } - - /// - /// Creates and fills a PathTargetInfoV2 object - /// - /// The newly created PathTargetInfoV2 object - public PathTargetInfoV2 GetPathTargetInfoV2() - { - var pathAdvancedTargetInfo = GetPathAdvancedTargetInfo(); - - return new PathTargetInfoV2(DisplayDevice.DisplayId, WindowsCCDTargetId, pathAdvancedTargetInfo); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/ScanOutInformation.cs b/app/NvAPIWrapper/Display/ScanOutInformation.cs deleted file mode 100644 index 9ec2c09b..00000000 --- a/app/NvAPIWrapper/Display/ScanOutInformation.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.General.Structures; -using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; - -namespace NvAPIWrapper.Display -{ - /// - /// Contains information regarding the scan-out buffer settings of a display device - /// - public class ScanOutInformation - { - internal ScanOutInformation(DisplayDevice displayDevice) - { - DisplayDevice = displayDevice; - } - - /// - /// Gets the clone importance assigned to the target if the target is a cloned view of the SourceDesktopRectangle - /// (0:primary,1 secondary,...). - /// - public uint CloneImportance - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).CloneImportance; - } - - /// - /// Gets the display device that this instance describes - /// - public DisplayDevice DisplayDevice { get; } - - /// - /// Gets a boolean value indicating if the display device scan out output is warped - /// - public bool IsDisplayWarped - { - get => DisplayApi.GetScanOutWarpingState(DisplayDevice.DisplayId).IsEnabled; - } - - /// - /// Gets a boolean value indicating if the display device intensity is modified - /// - public bool IsIntensityModified - { - get => DisplayApi.GetScanOutIntensityState(DisplayDevice.DisplayId).IsEnabled; - } - - /// - /// Gets the operating system display device rectangle in desktop coordinates displayId is scanning out from. - /// - public Rectangle SourceDesktopRectangle - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceDesktopRectangle; - } - - /// - /// Gets the rotation performed between the SourceViewPortRectangle and the TargetViewPortRectangle. - /// - public Rotate SourceToTargetRotation - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceToTargetRotation; - } - - /// - /// Gets the area inside the SourceDesktopRectangle which is scanned out to the display. - /// - public Rectangle SourceViewPortRectangle - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).SourceViewPortRectangle; - } - - /// - /// Gets the vertical size of the active resolution scanned out to the display. - /// - public uint TargetDisplayHeight - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetDisplayHeight; - } - - /// - /// Gets the horizontal size of the active resolution scanned out to the display. - /// - public uint TargetDisplayWidth - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetDisplayWidth; - } - - /// - /// Gets the area inside the rectangle described by targetDisplayWidth/Height SourceViewPortRectangle is scanned out - /// to. - /// - public Rectangle TargetViewPortRectangle - { - get => DisplayApi.GetScanOutConfiguration(DisplayDevice.DisplayId).TargetViewPortRectangle; - } - - /// - /// Disables the intensity modification on the display device scan-out buffer. - /// - /// A boolean value that indicates whether the settings will be kept over a reboot. - public void DisableIntensityModifications(out bool isSticky) - { - DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, null, out isSticky); - } - - /// - /// Disables the warping of display device scan-out buffer. - /// - /// A boolean value that indicates whether the settings will be kept over a reboot. - public void DisableWarping(out bool isSticky) - { - var vorticesCount = 0; - DisplayApi.SetScanOutWarping(DisplayDevice.DisplayId, null, ref vorticesCount, out isSticky); - } - - /// - /// Enables the intensity modification on the display device scan-out buffer. - /// - /// The intensity texture to apply to the scan-out buffer. - /// A boolean value that indicates whether the settings will be kept over a reboot. - public void EnableIntensityModifications(IntensityTexture intensityTexture, out bool isSticky) - { - using ( - var intensity = new ScanOutIntensityV1( - (uint) intensityTexture.Width, - (uint) intensityTexture.Height, - intensityTexture.ToFloatArray() - ) - ) - { - DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, intensity, out isSticky); - } - } - - /// - /// Enables the intensity modification on the display device scan-out buffer. - /// - /// The intensity texture to apply to the scan-out buffer. - /// The offset texture to apply to the scan-out buffer. - /// A boolean value that indicates whether the settings will be kept over a reboot. - public void EnableIntensityModifications( - IntensityTexture intensityTexture, - FloatTexture offsetTexture, - out bool isSticky) - { - using ( - var intensity = new ScanOutIntensityV2( - (uint) intensityTexture.Width, - (uint) intensityTexture.Height, - intensityTexture.ToFloatArray(), - (uint) offsetTexture.Channels, - offsetTexture.ToFloatArray() - ) - ) - { - DisplayApi.SetScanOutIntensity(DisplayDevice.DisplayId, intensity, out isSticky); - } - } - - /// - /// Enables the warping of display device scan-out buffer - /// - /// The type of warping vortexes. - /// An array of warping vortexes. - /// The rectangle in desktop coordinates describing the source area for the warping. - /// A boolean value that indicates whether the settings will be kept over a reboot. - // ReSharper disable once TooManyArguments - public void EnableWarping( - WarpingVerticeFormat warpingVerticeFormat, - XYUVRQVortex[] vortices, - Rectangle textureRectangle, - out bool isSticky) - { - using ( - var warping = new ScanOutWarpingV1( - warpingVerticeFormat, - vortices.SelectMany(vortex => vortex.AsFloatArray()).ToArray(), - textureRectangle - ) - ) - { - var vorticesCount = vortices.Length; - DisplayApi.SetScanOutWarping(DisplayDevice.DisplayId, warping, ref vorticesCount, out isSticky); - } - } - - /// - /// Queries the current state of one of the various scan-out composition parameters. - /// - /// The scan-out composition parameter. - /// The additional value included with the parameter value. - /// The scan-out composition parameter value. - public ScanOutCompositionParameterValue GetCompositionParameterValue( - ScanOutCompositionParameter parameter, - out float additionalValue) - { - return DisplayApi.GetScanOutCompositionParameter(DisplayDevice.DisplayId, parameter, out additionalValue); - } - - - /// - /// Sets the current state of one of the various scan-out composition parameters. - /// - /// The scan-out composition parameter. - /// The scan-out composition parameter value. - /// The additional value included with the parameter value. - public void SetCompositionParameterValue( - ScanOutCompositionParameter parameter, - ScanOutCompositionParameterValue parameterValue, - float additionalValue) - { - DisplayApi.SetScanOutCompositionParameter(DisplayDevice.DisplayId, parameter, parameterValue, - ref additionalValue); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/UnAttachedDisplay.cs b/app/NvAPIWrapper/Display/UnAttachedDisplay.cs deleted file mode 100644 index 1af2c330..00000000 --- a/app/NvAPIWrapper/Display/UnAttachedDisplay.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.GPU; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents an unattached display - /// - public class UnAttachedDisplay : IEquatable - { - /// - /// Creates a new UnAttachedDisplay - /// - /// Handle of the unattached display device - public UnAttachedDisplay(UnAttachedDisplayHandle handle) - { - Handle = handle; - } - - /// - /// Creates a new UnAttachedDisplay - /// - /// Name of the unattached display device - public UnAttachedDisplay(string displayName) - { - Handle = DisplayApi.GetAssociatedUnAttachedNvidiaDisplayHandle(displayName); - } - - /// - /// Gets display handle - /// - public UnAttachedDisplayHandle Handle { get; } - - /// - /// Gets display name - /// - public string Name - { - get => DisplayApi.GetUnAttachedAssociatedDisplayName(Handle); - } - - /// - /// Gets corresponding physical GPU - /// - public PhysicalGPU PhysicalGPU - { - get => new PhysicalGPU(GPUApi.GetPhysicalGPUFromUnAttachedDisplay(Handle)); - } - - /// - /// Checks for equality with a UnAttachedDisplay instance - /// - /// The Display object to check with - /// true if both objects are equal, otherwise false - public bool Equals(UnAttachedDisplay other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Handle.Equals(other.Handle); - } - - /// - /// This function returns all unattached NVIDIA displays - /// Note: Display handles can get invalidated on a modeset. - /// - /// An array of Display objects - public static UnAttachedDisplay[] GetUnAttachedDisplays() - { - return - DisplayApi.EnumNvidiaUnAttachedDisplayHandle().Select(handle => new UnAttachedDisplay(handle)) - .ToArray(); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(UnAttachedDisplay left, UnAttachedDisplay right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(UnAttachedDisplay left, UnAttachedDisplay right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((UnAttachedDisplay) obj); - } - - /// - public override int GetHashCode() - { - return Handle.GetHashCode(); - } - - /// - public override string ToString() - { - return Name; - } - - /// - /// Creates a new active attached display from this unattached display - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// - /// An active attached display - public Display CreateDisplay() - { - return new Display(DisplayApi.CreateDisplayFromUnAttachedDisplay(Handle)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Display/XYUVRQVortex.cs b/app/NvAPIWrapper/Display/XYUVRQVortex.cs deleted file mode 100644 index f90a955e..00000000 --- a/app/NvAPIWrapper/Display/XYUVRQVortex.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NvAPIWrapper.Display -{ - /// - /// Represents a XYUVRQ scan-out warping vortex - /// - public class XYUVRQVortex : IEquatable - { - /// - /// Creates a new instance of . - /// - /// The target view port mesh horizontal coordinate - /// The target view port mesh vertical coordinate - /// The desktop view port texture horizontal coordinate - /// The desktop view port texture vertical coordinate - /// The 3D warp perspective R factor - /// The 3D warp perspective Q factor - // ReSharper disable once TooManyDependencies - public XYUVRQVortex(int x, int y, int u, int v, float r, float q) - { - X = x; - Y = y; - U = u; - V = v; - R = r; - Q = q; - } - - /// - /// 3D warp perspective Q factor - /// - public float Q { get; } - - /// - /// 3D warp perspective R factor - /// - public float R { get; } - - /// - /// Desktop view port texture horizontal coordinate - /// - public int U { get; } - - /// - /// Desktop view port texture vertical coordinate - /// - public int V { get; } - - /// - /// Target view port mesh horizontal coordinate - /// - public int X { get; } - - /// - /// Target view port mesh vertical coordinate - /// - public int Y { get; } - - /// - public bool Equals(XYUVRQVortex other) - { - if (other == null) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Math.Abs(Q - other.Q) < 0.0001 && - Math.Abs(R - other.R) < 0.0001 && - U == other.U && - V == other.V && - X == other.X && - Y == other.Y; - } - - /// - /// Parses an array of floats and returns the corresponding s. - /// - /// The array of float representing one or more s. - /// Instances of . - public static IEnumerable FromFloatArray(float[] floats) - { - for (var i = 0; i + 6 <= floats.Length; i += 6) - { - yield return new XYUVRQVortex( - (int) floats[i], - (int) floats[i + 1], - (int) floats[i + 2], - (int) floats[i + 3], - floats[i + 4], - floats[i + 5] - ); - } - } - - /// - /// Compares two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are equal, otherwise - public static bool operator ==(XYUVRQVortex left, XYUVRQVortex right) - { - return Equals(left, right) || left?.Equals(right) == true; - } - - /// - /// Compares two instance of for in-equality. - /// - /// The first instance. - /// The second instance. - /// if both instances are not equal, otherwise - public static bool operator !=(XYUVRQVortex left, XYUVRQVortex right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return Equals(obj as XYUVRQVortex); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = Q.GetHashCode(); - hashCode = (hashCode * 397) ^ R.GetHashCode(); - hashCode = (hashCode * 397) ^ U; - hashCode = (hashCode * 397) ^ V; - hashCode = (hashCode * 397) ^ X; - hashCode = (hashCode * 397) ^ Y; - - return hashCode; - } - } - - /// - /// Returns this instance of as a float array. - /// - /// An array of float values representing this instance of . - public float[] AsFloatArray() - { - return new[] {X, Y, U, V, R, Q}; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/AGPInformation.cs b/app/NvAPIWrapper/GPU/AGPInformation.cs deleted file mode 100644 index 25a80841..00000000 --- a/app/NvAPIWrapper/GPU/AGPInformation.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the accelerated graphics connection - /// - public class AGPInformation - { - internal AGPInformation(int aperture, int currentRate) - { - ApertureInMB = aperture; - CurrentRate = currentRate; - } - - /// - /// Gets AGP aperture in megabytes - /// - public int ApertureInMB { get; } - - /// - /// Gets current AGP Rate (0 = AGP not present, 1 = 1x, 2 = 2x, etc.) - /// - public int CurrentRate { get; } - - /// - public override string ToString() - { - return $"AGP Aperture: {ApertureInMB}MB, Current Rate: {CurrentRate}x"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/ECCMemoryInformation.cs b/app/NvAPIWrapper/GPU/ECCMemoryInformation.cs deleted file mode 100644 index 486182df..00000000 --- a/app/NvAPIWrapper/GPU/ECCMemoryInformation.cs +++ /dev/null @@ -1,201 +0,0 @@ -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the ECC memory - /// - public class ECCMemoryInformation - { - internal ECCMemoryInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the number of aggregated ECC memory double bit errors - /// - public ulong AggregatedDoubleBitErrors - { - get - { - if (!IsSupported || !IsEnabled) - { - return 0; - } - - return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).AggregatedErrors.DoubleBitErrors; - } - } - - - /// - /// Gets the number of aggregated ECC memory single bit errors - /// - public ulong AggregatedSingleBitErrors - { - get - { - if (!IsSupported || !IsEnabled) - { - return 0; - } - - return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).AggregatedErrors.SingleBitErrors; - } - } - - /// - /// Gets the ECC memory configuration in regard to how changes are applied - /// - public ECCConfiguration Configuration - { - get - { - try - { - return GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).ConfigurationOptions; - } - catch - { - return ECCConfiguration.NotSupported; - } - } - } - - /// - /// Gets the number of current ECC memory double bit errors - /// - public ulong CurrentDoubleBitErrors - { - get - { - if (!IsSupported || !IsEnabled) - { - return 0; - } - - return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).CurrentErrors.DoubleBitErrors; - } - } - - /// - /// Gets the number of current ECC memory single bit errors - /// - public ulong CurrentSingleBitErrors - { - get - { - if (!IsSupported || !IsEnabled) - { - return 0; - } - - return GPUApi.GetECCErrorInfo(PhysicalGPU.Handle).CurrentErrors.SingleBitErrors; - } - } - - /// - /// Gets a boolean value indicating if ECC memory error correction is enabled - /// - - public bool IsEnabled - { - get => IsSupported && - GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).IsEnabled && - GPUApi.GetECCConfigurationInfo(PhysicalGPU.Handle).IsEnabled; - } - - /// - /// Gets a boolean value indicating if ECC memory is enabled by default - /// - public bool IsEnabledByDefault - { - get => IsSupported && - GPUApi.GetECCConfigurationInfo(PhysicalGPU.Handle).IsEnabledByDefault; - } - - /// - /// Gets a boolean value indicating if ECC memory is supported and available - /// - public bool IsSupported - { - get - { - try - { - return GPUApi.GetECCStatusInfo(PhysicalGPU.Handle).IsSupported; - } - catch - { - return false; - } - } - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - public override string ToString() - { - if (!IsSupported) - { - return "[Not Supported]"; - } - - if (!IsEnabled) - { - return "[Disabled]"; - } - - return - $"{CurrentSingleBitErrors}, {CurrentDoubleBitErrors} ({AggregatedSingleBitErrors}, {AggregatedDoubleBitErrors})"; - } - - /// - /// Clears aggregated error counters. - /// - public void ClearAggregatedErrors() - { - GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, false, true); - } - - /// - /// Clears current error counters. - /// - public void ClearCurrentErrors() - { - GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, true, false); - } - - /// - /// Clears all error counters. - /// - public void ClearErrors() - { - GPUApi.ResetECCErrorInfo(PhysicalGPU.Handle, true, true); - } - - /// - /// Disables ECC memory error correction. - /// - /// A boolean value to indicate if this change should get applied immediately - public void Disable(bool immediate) - { - GPUApi.SetECCConfiguration(PhysicalGPU.Handle, false, immediate); - } - - /// - /// Enables ECC memory error correction. - /// - /// A boolean value to indicate if this change should get applied immediately - public void Enable(bool immediate) - { - GPUApi.SetECCConfiguration(PhysicalGPU.Handle, true, immediate); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUArchitectInformation.cs b/app/NvAPIWrapper/GPU/GPUArchitectInformation.cs deleted file mode 100644 index c489e25f..00000000 --- a/app/NvAPIWrapper/GPU/GPUArchitectInformation.cs +++ /dev/null @@ -1,115 +0,0 @@ -using NvAPIWrapper.Native; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains physical GPU architect information - /// - public class GPUArchitectInformation - { - internal GPUArchitectInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets total number of cores defined for this GPU, or zero for older architectures - /// - public int NumberOfCores - { - get => (int) GPUApi.GetGPUCoreCount(PhysicalGPU.Handle); - } - - /// - /// Gets the number of graphics processing clusters (aka GPU Partitions) - /// - public int NumberOfGPC - { - get => (int) GPUApi.GetPartitionCount(PhysicalGPU.Handle); - } - - /// - /// Gets the number of render output units - /// - public int NumberOfROPs - { - get => (int) GPUApi.GetROPCount(PhysicalGPU.Handle); - } - - /// - /// Gets the number of shader pipelines - /// - public int NumberOfShaderPipelines - { - get => (int) GPUApi.GetShaderPipeCount(PhysicalGPU.Handle); - } - - /// - /// Gets the number of shader sub pipelines - /// - public int NumberOfShaderSubPipelines - { - get => (int) GPUApi.GetShaderSubPipeCount(PhysicalGPU.Handle); - } - - /// - /// Gets the number of video processing engines - /// - public int NumberOfVPEs - { - get => (int) GPUApi.GetVPECount(PhysicalGPU.Handle); - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets the GPU revision number (should be displayed as a hex string) - /// - public int Revision - { - get => (int) GPUApi.GetArchitectInfo(PhysicalGPU.Handle).Revision; - } - - /// - /// Gets the GPU short name (aka Codename) - /// - public string ShortName - { - get => GPUApi.GetShortName(PhysicalGPU.Handle); - } - - /// - /// Gets the total number of streaming multiprocessors - /// - public int TotalNumberOfSMs - { - get => (int) GPUApi.GetTotalSMCount(PhysicalGPU.Handle); - } - - - /// - /// Gets the total number of streaming processors - /// - public int TotalNumberOfSPs - { - get => (int) GPUApi.GetTotalSPCount(PhysicalGPU.Handle); - } - - /// - /// Gets the total number of texture processing clusters - /// - public int TotalNumberOfTPCs - { - get => (int) GPUApi.GetTotalTPCCount(PhysicalGPU.Handle); - } - - /// - public override string ToString() - { - return $"[{ShortName} REV{Revision:X}] Cores: {NumberOfCores}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUBusInformation.cs b/app/NvAPIWrapper/GPU/GPUBusInformation.cs deleted file mode 100644 index 4e47776d..00000000 --- a/app/NvAPIWrapper/GPU/GPUBusInformation.cs +++ /dev/null @@ -1,118 +0,0 @@ -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the GPU bus - /// - public class GPUBusInformation - { - internal GPUBusInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets accelerated graphics port information - /// - public AGPInformation AGPInformation - { - get - { - if (BusType != GPUBusType.AGP) - { - return null; - } - - return new AGPInformation( - GPUApi.GetAGPAperture(PhysicalGPU.Handle), - GPUApi.GetCurrentAGPRate(PhysicalGPU.Handle) - ); - } - } - - /// - /// Gets the bus identification - /// - public int BusId - { - get => GPUApi.GetBusId(PhysicalGPU.Handle); - } - - /// - /// Gets the bus slot identification - /// - public int BusSlot - { - get => GPUApi.GetBusSlotId(PhysicalGPU.Handle); - } - - /// - /// Gets the the bus type - /// - public GPUBusType BusType - { - get => GPUApi.GetBusType(PhysicalGPU.Handle); - } - - /// - /// Gets number of PCIe lanes being used for the PCIe interface downstream - /// - public int CurrentPCIeLanes - { - get - { - if (BusType == GPUBusType.PCIExpress) - { - return GPUApi.GetCurrentPCIEDownStreamWidth(PhysicalGPU.Handle); - } - - return 0; - } - } - - /// - /// Gets GPU interrupt number - /// - public int IRQ - { - get => GPUApi.GetIRQ(PhysicalGPU.Handle); - } - - /// - /// Gets the PCI identifiers - /// - public PCIIdentifiers PCIIdentifiers - { - get - { - if (BusType == GPUBusType.FPCI || BusType == GPUBusType.PCI || BusType == GPUBusType.PCIExpress) - { - GPUApi.GetPCIIdentifiers( - PhysicalGPU.Handle, - out var deviceId, - out var subSystemId, - out var revisionId, - out var extDeviceId - ); - - return new PCIIdentifiers(deviceId, subSystemId, revisionId, (int) extDeviceId); - } - - return null; - } - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - public override string ToString() - { - return $"[{BusType}] Bus #{BusId}, Slot #{BusSlot}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUCooler.cs b/app/NvAPIWrapper/GPU/GPUCooler.cs deleted file mode 100644 index 86d68166..00000000 --- a/app/NvAPIWrapper/GPU/GPUCooler.cs +++ /dev/null @@ -1,130 +0,0 @@ -using System; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding a GPU cooler entry - /// - public class GPUCooler - { - internal GPUCooler(int coolerId, PrivateCoolerSettingsV1.CoolerSetting coolerSetting, int currentRPM = -1) - { - CoolerId = coolerId; - CurrentLevel = (int) coolerSetting.CurrentLevel; - DefaultMinimumLevel = (int) coolerSetting.DefaultMinimumLevel; - DefaultMaximumLevel = (int) coolerSetting.DefaultMaximumLevel; - CurrentMinimumLevel = (int) coolerSetting.CurrentMinimumLevel; - CurrentMaximumLevel = (int) coolerSetting.CurrentMaximumLevel; - CoolerType = coolerSetting.CoolerType; - CoolerController = coolerSetting.CoolerController; - DefaultPolicy = coolerSetting.DefaultPolicy; - CurrentPolicy = coolerSetting.CurrentPolicy; - Target = coolerSetting.Target; - ControlMode = coolerSetting.ControlMode; - CurrentFanSpeedInRPM = currentRPM; - } - - // ReSharper disable once TooManyDependencies - internal GPUCooler( - PrivateFanCoolersInfoV1.FanCoolersInfoEntry infoEntry, - PrivateFanCoolersStatusV1.FanCoolersStatusEntry statusEntry, - PrivateFanCoolersControlV1.FanCoolersControlEntry controlEntry) - { - if (infoEntry.CoolerId != statusEntry.CoolerId || statusEntry.CoolerId != controlEntry.CoolerId) - { - throw new ArgumentException("Passed arguments are meant to be for different coolers."); - } - - CoolerId = (int) statusEntry.CoolerId; - CurrentLevel = (int) statusEntry.CurrentLevel; - DefaultMinimumLevel = (int) statusEntry.CurrentMinimumLevel; - DefaultMaximumLevel = (int) statusEntry.CurrentMaximumLevel; - CurrentMinimumLevel = (int) statusEntry.CurrentMinimumLevel; - CurrentMaximumLevel = (int) statusEntry.CurrentMaximumLevel; - CoolerType = CoolerType.Fan; - CoolerController = CoolerController.Internal; - DefaultPolicy = CoolerPolicy.None; - CurrentPolicy = controlEntry.ControlMode == FanCoolersControlMode.Manual - ? CoolerPolicy.Manual - : CoolerPolicy.None; - Target = CoolerTarget.All; - ControlMode = CoolerControlMode.Variable; - CurrentFanSpeedInRPM = (int) statusEntry.CurrentRPM; - } - - /// - /// Gets the cooler control mode - /// - public CoolerControlMode ControlMode { get; } - - /// - /// Gets the cooler controller - /// - public CoolerController CoolerController { get; } - - /// - /// Gets the cooler identification number or index - /// - public int CoolerId { get; } - - /// - /// Gets the cooler type - /// - public CoolerType CoolerType { get; } - - /// - /// Gets the GPU fan speed in revolutions per minute - /// - public int CurrentFanSpeedInRPM { get; } - - /// - /// Gets the cooler current level in percentage - /// - public int CurrentLevel { get; } - - - /// - /// Gets the cooler current maximum level in percentage - /// - public int CurrentMaximumLevel { get; } - - - /// - /// Gets the cooler current minimum level in percentage - /// - public int CurrentMinimumLevel { get; } - - /// - /// Gets the cooler current policy - /// - public CoolerPolicy CurrentPolicy { get; } - - /// - /// Gets the cooler default maximum level in percentage - /// - public int DefaultMaximumLevel { get; } - - /// - /// Gets the cooler default minimum level in percentage - /// - public int DefaultMinimumLevel { get; } - - /// - /// Gets the cooler default policy - /// - public CoolerPolicy DefaultPolicy { get; } - - /// - /// Gets the cooler target - /// - public CoolerTarget Target { get; } - - /// - public override string ToString() - { - return $"[{CoolerId} @ {CoolerController}] {Target}: {CurrentLevel}%"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUCoolerInformation.cs b/app/NvAPIWrapper/GPU/GPUCoolerInformation.cs deleted file mode 100644 index 9be8cc86..00000000 --- a/app/NvAPIWrapper/GPU/GPUCoolerInformation.cs +++ /dev/null @@ -1,340 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the GPU coolers and current fan speed - /// - public class GPUCoolerInformation - { - internal GPUCoolerInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - - // TODO: Add Support For Pascal Only Policy Table Method - // TODO: GPUApi.GetCoolerPolicyTable & GPUApi.SetCoolerPolicyTable & GPUApi.RestoreCoolerPolicyTable - // TODO: Better support of ClientFanCoolers set of APIs - } - - /// - /// Gets a list of all available coolers along with their current settings and status - /// - public IEnumerable Coolers - { - get - { - PrivateCoolerSettingsV1? settings = null; - - try - { - settings = GPUApi.GetCoolerSettings(PhysicalGPU.Handle); - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.NotSupported) - { - throw; - } - } - - if (settings != null) - { - for (var i = 0; i < settings.Value.CoolerSettings.Length; i++) - { - if (i == 0) - { - var currentRPM = -1; - try - { - currentRPM = (int)GPUApi.GetTachReading(PhysicalGPU.Handle); - } - catch (NVIDIAApiException) - { - // ignored - } - - if (currentRPM >= 0) - { - yield return new GPUCooler( - i, - settings.Value.CoolerSettings[i], - currentRPM - ); - continue; - } - } - - yield return new GPUCooler( - i, - settings.Value.CoolerSettings[i] - ); - } - - yield break; - } - - PrivateFanCoolersStatusV1? status = null; - PrivateFanCoolersInfoV1? info = null; - PrivateFanCoolersControlV1? control = null; - - try - { - status = GPUApi.GetClientFanCoolersStatus(PhysicalGPU.Handle); - info = GPUApi.GetClientFanCoolersInfo(PhysicalGPU.Handle); - control = GPUApi.GetClientFanCoolersControl(PhysicalGPU.Handle); - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.NotSupported) - { - throw; - } - } - - if (status != null && info != null && control != null) - { - for (var i = 0; i < status.Value.FanCoolersStatusEntries.Length; i++) - { - if (info.Value.FanCoolersInfoEntries.Length > i && - control.Value.FanCoolersControlEntries.Length > i) - { - yield return new GPUCooler( - info.Value.FanCoolersInfoEntries[i], - status.Value.FanCoolersStatusEntries[i], - control.Value.FanCoolersControlEntries[i] - ); - } - } - - yield break; - } - - throw new NVIDIAApiException(Status.NotSupported); - } - } - - /// - /// Gets the GPU fan speed in revolutions per minute - /// - public int CurrentFanSpeedInRPM - { - get - { - try - { - return (int) GPUApi.GetTachReading(PhysicalGPU.Handle); - } - catch - { - return Coolers.FirstOrDefault(cooler => cooler.Target == CoolerTarget.All)?.CurrentFanSpeedInRPM ?? - 0; - } - } - } - - /// - /// Gets the current fan speed in percentage if available - /// - public int CurrentFanSpeedLevel - { - get - { - try - { - return (int) GPUApi.GetCurrentFanSpeedLevel(PhysicalGPU.Handle); - } - catch - { - return Coolers.FirstOrDefault(cooler => cooler.Target == CoolerTarget.All)?.CurrentLevel ?? 0; - } - } - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - public override string ToString() - { - return $"{CurrentFanSpeedInRPM} RPM ({CurrentFanSpeedLevel}%)"; - } - - /// - /// Resets all cooler settings to default. - /// - public void RestoreCoolerSettingsToDefault() - { - RestoreCoolerSettingsToDefault(Coolers.Select(cooler => cooler.CoolerId).ToArray()); - } - - /// - /// Resets one or more cooler settings to default. - /// - /// The cooler identification numbers (indexes) to reset their settings to default. - public void RestoreCoolerSettingsToDefault(params int[] coolerIds) - { - var availableCoolerIds = Coolers.Select(cooler => cooler.CoolerId).ToArray(); - - if (coolerIds.Any(i => !availableCoolerIds.Contains(i))) - { - throw new ArgumentException("Invalid cooler identification number provided.", nameof(coolerIds)); - } - - try - { - GPUApi.RestoreCoolerSettings(PhysicalGPU.Handle, coolerIds.Select(i => (uint) i).ToArray()); - - return; - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.NotSupported) - { - throw; - } - } - - var currentControl = GPUApi.GetClientFanCoolersControl(PhysicalGPU.Handle); - var newControl = new PrivateFanCoolersControlV1( - currentControl.FanCoolersControlEntries.Select( - entry => coolerIds.Contains((int) entry.CoolerId) - ? new PrivateFanCoolersControlV1.FanCoolersControlEntry( - entry.CoolerId, - FanCoolersControlMode.Auto - ) - : entry - ) - .ToArray(), - currentControl.UnknownUInt - ); - GPUApi.SetClientFanCoolersControl(PhysicalGPU.Handle, newControl); - } - - /// - /// Changes a cooler settings by modifying the policy and the current level - /// - /// The cooler identification number (index) to change the settings. - /// The new cooler policy. - /// The new cooler level. Valid only if policy is set to manual. - // ReSharper disable once TooManyDeclarations - public void SetCoolerSettings(int coolerId, CoolerPolicy policy, int newLevel) - { - if (Coolers.All(cooler => cooler.CoolerId != coolerId)) - { - throw new ArgumentException("Invalid cooler identification number provided.", nameof(coolerId)); - } - - try - { - GPUApi.SetCoolerLevels( - PhysicalGPU.Handle, - (uint) coolerId, - new PrivateCoolerLevelsV1(new[] - { - new PrivateCoolerLevelsV1.CoolerLevel(policy, (uint) newLevel) - } - ), - 1 - ); - - return; - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.NotSupported) - { - throw; - } - } - - var currentControl = GPUApi.GetClientFanCoolersControl(PhysicalGPU.Handle); - var newControl = new PrivateFanCoolersControlV1( - currentControl.FanCoolersControlEntries.Select( - entry => entry.CoolerId == coolerId - ? new PrivateFanCoolersControlV1.FanCoolersControlEntry( - entry.CoolerId, - policy == CoolerPolicy.Manual - ? FanCoolersControlMode.Manual - : FanCoolersControlMode.Auto, - policy == CoolerPolicy.Manual ? (uint)newLevel : 0u) - : entry - ) - .ToArray(), - currentControl.UnknownUInt - ); - GPUApi.SetClientFanCoolersControl(PhysicalGPU.Handle, newControl); - } - - /// - /// Changes a cooler setting by modifying the policy - /// - /// The cooler identification number (index) to change the settings. - /// The new cooler policy. - // ReSharper disable once TooManyDeclarations - public void SetCoolerSettings(int coolerId, CoolerPolicy policy) - { - if (Coolers.All(cooler => cooler.CoolerId != coolerId)) - { - throw new ArgumentException("Invalid cooler identification number provided.", nameof(coolerId)); - } - - try - { - GPUApi.SetCoolerLevels( - PhysicalGPU.Handle, - (uint) coolerId, - new PrivateCoolerLevelsV1(new[] - { - new PrivateCoolerLevelsV1.CoolerLevel(policy) - } - ), - 1 - ); - - return; - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.NotSupported) - { - throw; - } - } - - var currentControl = GPUApi.GetClientFanCoolersControl(PhysicalGPU.Handle); - var newControl = new PrivateFanCoolersControlV1( - currentControl.FanCoolersControlEntries.Select( - entry => entry.CoolerId == coolerId - ? new PrivateFanCoolersControlV1.FanCoolersControlEntry( - entry.CoolerId, - policy == CoolerPolicy.Manual - ? FanCoolersControlMode.Manual - : FanCoolersControlMode.Auto) - : entry - ) - .ToArray(), - currentControl.UnknownUInt - ); - GPUApi.SetClientFanCoolersControl(PhysicalGPU.Handle, newControl); - } - - /// - /// Changes a cooler settings by modifying the policy to manual and sets a new level - /// - /// The cooler identification number (index) to change the settings. - /// The new cooler level. - public void SetCoolerSettings(int coolerId, int newLevel) - { - SetCoolerSettings(coolerId, CoolerPolicy.Manual, newLevel); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUMemoryInformation.cs b/app/NvAPIWrapper/GPU/GPUMemoryInformation.cs deleted file mode 100644 index 145403fd..00000000 --- a/app/NvAPIWrapper/GPU/GPUMemoryInformation.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information regarding the available and total memory as well as the type of memory and other information - /// regarding the GPU RAM and frame buffer - /// - public class GPUMemoryInformation : IDisplayDriverMemoryInfo - { - internal GPUMemoryInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the frame buffer bandwidth - /// - - public int FrameBufferBandwidth - { - get - { - GPUApi.GetFrameBufferWidthAndLocation(PhysicalGPU.Handle, out var width, out _); - - return (int) width; - } - } - - /// - /// Gets the frame buffer location index - /// - public int FrameBufferLocation - { - get - { - GPUApi.GetFrameBufferWidthAndLocation(PhysicalGPU.Handle, out _, out var location); - - return (int) location; - } - } - - /// - /// Gets the internal clock to bus clock factor based on the type of RAM - /// - public int InternalClockToBusClockFactor - { - get => GetMemoryBusClockFactor(RAMType); - } - - /// - /// Gets the internal clock to transfer rate factor based on the type of RAM - /// - public int InternalClockToTransferRateFactor - { - get => GetMemoryTransferRateFactor(RAMType); - } - - /// - /// Gets GPU physical frame buffer size in KB. This does NOT include any system RAM that may be dedicated for use by - /// the GPU. - /// - public int PhysicalFrameBufferSizeInkB - { - get => GPUApi.GetPhysicalFrameBufferSize(PhysicalGPU.Handle); - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets the number of memory banks - /// - public uint RAMBanks - { - get => GPUApi.GetRAMBankCount(PhysicalGPU.Handle); - } - - /// - /// Gets the memory bus width - /// - public uint RAMBusWidth - { - get => GPUApi.GetRAMBusWidth(PhysicalGPU.Handle); - } - - /// - /// Gets the memory maker (brand) - /// - public GPUMemoryMaker RAMMaker - { - get => GPUApi.GetRAMMaker(PhysicalGPU.Handle); - } - - /// - /// Gets the memory type - /// - public GPUMemoryType RAMType - { - get => GPUApi.GetRAMType(PhysicalGPU.Handle); - } - - /// - /// Gets virtual size of frame-buffer in KB for this GPU. This includes the physical RAM plus any system RAM that has - /// been dedicated for use by the GPU. - /// - public int VirtualFrameBufferSizeInkB - { - get => GPUApi.GetVirtualFrameBufferSize(PhysicalGPU.Handle); - } - - /// - public uint AvailableDedicatedVideoMemoryInkB - { - get => GPUApi.GetMemoryInfo(PhysicalGPU.Handle).AvailableDedicatedVideoMemoryInkB; - } - - /// - public uint CurrentAvailableDedicatedVideoMemoryInkB - { - get => GPUApi.GetMemoryInfo(PhysicalGPU.Handle).CurrentAvailableDedicatedVideoMemoryInkB; - } - - /// - public uint DedicatedVideoMemoryInkB - { - get => GPUApi.GetMemoryInfo(PhysicalGPU.Handle).DedicatedVideoMemoryInkB; - } - - /// - public uint SharedSystemMemoryInkB - { - get => GPUApi.GetMemoryInfo(PhysicalGPU.Handle).SharedSystemMemoryInkB; - } - - /// - public uint SystemVideoMemoryInkB - { - get => GPUApi.GetMemoryInfo(PhysicalGPU.Handle).SystemVideoMemoryInkB; - } - - /// - /// Gets the memory bus clock to internal memory clock factor - /// - /// - /// The value of X in X(InternalMemoryClock)=(BusMemoryClock) - public static int GetMemoryBusClockFactor(GPUMemoryType memoryType) - { - switch (memoryType) - { - case GPUMemoryType.SDRAM: - - // Bus Clocks Per Internal Clock = 1 - return 1; - case GPUMemoryType.DDR1: - case GPUMemoryType.DDR2: - case GPUMemoryType.DDR3: - case GPUMemoryType.GDDR2: - case GPUMemoryType.GDDR3: - case GPUMemoryType.GDDR4: - case GPUMemoryType.LPDDR2: - case GPUMemoryType.GDDR5: - case GPUMemoryType.GDDR5X: - - // Bus Clocks Per Internal Clock = 2 - return 2; - default: - - throw new ArgumentOutOfRangeException(nameof(memoryType)); - } - } - - /// - /// Gets the number of transfers per internal memory clock factor - /// - /// - /// The value of X in X(InternalMemoryClock)=(OperationsPerSecond) - public static int GetMemoryTransferRateFactor(GPUMemoryType memoryType) - { - switch (memoryType) - { - case GPUMemoryType.SDRAM: - - // Transfers Per Internal Clock = 1 - return 1; - case GPUMemoryType.DDR1: - case GPUMemoryType.DDR2: - case GPUMemoryType.DDR3: - case GPUMemoryType.GDDR2: - case GPUMemoryType.GDDR3: - case GPUMemoryType.GDDR4: - case GPUMemoryType.LPDDR2: - - // Transfers Per Internal Clock = 1 - return 2; - case GPUMemoryType.GDDR5: - - // Transfers Per Internal Clock = 2 - return 4; - case GPUMemoryType.GDDR5X: - - // Transfers Per Internal Clock = 4 - return 8; - default: - - throw new ArgumentOutOfRangeException(nameof(memoryType)); - } - } - - /// - public override string ToString() - { - return - $"[{RAMMaker} {RAMType}] Total: {AvailableDedicatedVideoMemoryInkB:N0} kB - Available: {CurrentAvailableDedicatedVideoMemoryInkB:N0} kB"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUOutput.cs b/app/NvAPIWrapper/GPU/GPUOutput.cs deleted file mode 100644 index c9fb3b03..00000000 --- a/app/NvAPIWrapper/GPU/GPUOutput.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System; -using NvAPIWrapper.Display; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a single GPU output - /// - public class GPUOutput : IEquatable - { - internal GPUOutput(OutputId outputId, PhysicalGPUHandle gpuHandle) - { - OutputId = outputId; - OutputType = !gpuHandle.IsNull ? GPUApi.GetOutputType(gpuHandle, outputId) : OutputType.Unknown; - PhysicalGPU = new PhysicalGPU(gpuHandle); - } - - internal GPUOutput(OutputId outputId, PhysicalGPU gpu) - : this(outputId, gpu?.Handle ?? PhysicalGPUHandle.DefaultHandle) - { - PhysicalGPU = gpu; - } - - /// - /// Gets the corresponding Digital Vibrance Control information - /// - public DVCInformation DigitalVibranceControl - { - get => new DVCInformation(OutputId); - } - - /// - /// Gets the corresponding HUE information - /// - public HUEInformation HUEControl - { - get => new HUEInformation(OutputId); - } - - /// - /// Gets the output identification as a single bit unsigned integer - /// - public OutputId OutputId { get; } - - /// - /// Gets the output type - /// - public OutputType OutputType { get; } - - /// - /// Gets the corresponding physical GPU - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - public bool Equals(GPUOutput other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return PhysicalGPU.Equals(other.PhysicalGPU) && OutputId == other.OutputId; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(GPUOutput left, GPUOutput right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(GPUOutput left, GPUOutput right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((GPUOutput) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - return ((PhysicalGPU != null ? PhysicalGPU.GetHashCode() : 0) * 397) ^ (int) OutputId; - } - } - - /// - public override string ToString() - { - return $"{OutputId} {OutputType} @ {PhysicalGPU}"; - } - - /// - /// Overrides the refresh rate on this output. - /// The new refresh rate can be applied right away or deferred to be applied with the next OS - /// mode-set. - /// The override is good for only one mode-set (regardless whether it's deferred or immediate). - /// - /// The refresh rate to be applied. - /// - /// A boolean value indicating if the refresh rate override should be deferred to the next OS - /// mode-set. - /// - public void OverrideRefreshRate(float refreshRate, bool isDeferred = false) - { - DisplayApi.SetRefreshRateOverride(OutputId, refreshRate, isDeferred); - } - - /// - /// Reads data from the I2C bus - /// - /// The port id on which device is connected - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The length of the buffer to allocate for the read operation. - /// The target speed of the transaction in kHz - public byte[] ReadI2C( - byte? portId, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - uint readDataLength, - I2CSpeed speed = I2CSpeed.Default - ) - { - try - { - // ReSharper disable once InconsistentNaming - var i2cInfoV3 = new I2CInfoV3( - OutputId, - portId, - useDDCPort, - deviceAddress, - registerAddress, - readDataLength, - speed - ); - - return PhysicalGPU.ReadI2C(i2cInfoV3); - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.IncompatibleStructureVersion || portId != null) - { - throw; - } - - // ignore - } - - // ReSharper disable once InconsistentNaming - var i2cInfoV2 = new I2CInfoV2( - OutputId, - useDDCPort, - deviceAddress, - registerAddress, - readDataLength, - speed - ); - - return PhysicalGPU.ReadI2C(i2cInfoV2); - } - - /// - /// Writes data to the I2C bus - /// - /// The port id on which device is connected - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The payload data - /// The target speed of the transaction in kHz - public void WriteI2C( - byte? portId, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - byte[] data, - I2CSpeed speed = I2CSpeed.Default - ) - { - try - { - // ReSharper disable once InconsistentNaming - var i2cInfoV3 = new I2CInfoV3( - OutputId, - portId, - useDDCPort, - deviceAddress, - registerAddress, - data, - speed - ); - - PhysicalGPU.WriteI2C(i2cInfoV3); - - return; - } - catch (NVIDIAApiException e) - { - if (e.Status != Status.IncompatibleStructureVersion || portId != null) - { - throw; - } - - // ignore - } - - // ReSharper disable once InconsistentNaming - var i2cInfoV2 = new I2CInfoV2( - OutputId, - useDDCPort, - deviceAddress, - registerAddress, - data, - speed - ); - - PhysicalGPU.WriteI2C(i2cInfoV2); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceControl.cs b/app/NvAPIWrapper/GPU/GPUPerformanceControl.cs deleted file mode 100644 index 6174cf83..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceControl.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information regarding the GPU performance control and limitations - /// - public class GPUPerformanceControl - { - internal GPUPerformanceControl(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the current active performance limitation - /// - public PerformanceLimit CurrentActiveLimit - { - get => GPUApi.PerformancePoliciesGetStatus(PhysicalGPU.Handle).PerformanceLimit; - } - - /// - /// Gets the current performance decrease reason - /// - public PerformanceDecreaseReason CurrentPerformanceDecreaseReason - { - get => GPUApi.GetPerformanceDecreaseInfo(PhysicalGPU.Handle); - } - - - /// - /// Gets a boolean value indicating if no load limit is supported with this GPU - /// - public bool IsNoLoadLimitSupported - { - get => GPUApi.PerformancePoliciesGetInfo(PhysicalGPU.Handle).IsNoLoadLimitSupported; - } - - - /// - /// Gets a boolean value indicating if power limit is supported with this GPU - /// - public bool IsPowerLimitSupported - { - get => GPUApi.PerformancePoliciesGetInfo(PhysicalGPU.Handle).IsPowerLimitSupported; - } - - - /// - /// Gets a boolean value indicating if temperature limit is supported with this GPU - /// - public bool IsTemperatureLimitSupported - { - get => GPUApi.PerformancePoliciesGetInfo(PhysicalGPU.Handle).IsTemperatureLimitSupported; - } - - /// - /// Gets a boolean value indicating if voltage limit is supported with this GPU - /// - public bool IsVoltageLimitSupported - { - get => GPUApi.PerformancePoliciesGetInfo(PhysicalGPU.Handle).IsVoltageLimitSupported; - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets information regarding possible power limit policies and their acceptable range - /// - public IEnumerable PowerLimitInformation - { - get - { - return GPUApi.ClientPowerPoliciesGetInfo(PhysicalGPU.Handle).PowerPolicyInfoEntries - .Select(entry => new GPUPowerLimitInfo(entry)); - } - } - - /// - /// Gets the current active power limit policies - /// - public IEnumerable PowerLimitPolicies - { - get - { - // TODO: GPUApi.ClientPowerPoliciesSetStatus(); - return GPUApi.ClientPowerPoliciesGetStatus(PhysicalGPU.Handle).PowerPolicyStatusEntries - .Select(entry => new GPUPowerLimitPolicy(entry)); - } - } - - /// - /// Gets information regarding possible thermal limit policies and their acceptable range - /// - public IEnumerable ThermalLimitInformation - { - get - { - return GPUApi.GetThermalPoliciesInfo(PhysicalGPU.Handle).ThermalPoliciesInfoEntries - .Select(entry => new GPUThermalLimitInfo(entry)); - } - } - - /// - /// Gets the current active thermal limit policies - /// - public IEnumerable ThermalLimitPolicies - { - get - { - // TODO: GPUApi.SetThermalPoliciesStatus(); - return GPUApi.GetThermalPoliciesStatus(PhysicalGPU.Handle).ThermalPoliciesStatusEntries - .Select(entry => new GPUThermalLimitPolicy(entry)); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceState.cs b/app/NvAPIWrapper/GPU/GPUPerformanceState.cs deleted file mode 100644 index 8344dada..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceState.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Linq; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a performance state - /// - public class GPUPerformanceState - { - // ReSharper disable once TooManyDependencies - internal GPUPerformanceState( - int index, - IPerformanceState20 performanceState, - IPerformanceStates20ClockEntry[] statesClockEntries, - IPerformanceStates20VoltageEntry[] baseVoltageEntries, - PCIeInformation pcieInformation) - { - StateIndex = index; - StateId = performanceState.StateId; - IsReadOnly = !performanceState.IsEditable; - Clocks = statesClockEntries.Select(entry => new GPUPerformanceStateClock(entry)).ToArray(); - Voltages = baseVoltageEntries.Select(entry => new GPUPerformanceStateVoltage(entry)).ToArray(); - PCIeInformation = pcieInformation; - } - - /// - /// Gets a list of clocks associated with this performance state - /// - - public GPUPerformanceStateClock[] Clocks { get; } - - /// - /// Gets a boolean value indicating if this performance state is readonly - /// - public bool IsReadOnly { get; } - - /// - /// Gets the PCI-e information regarding this performance state. - /// - public PCIeInformation PCIeInformation { get; } - - /// - /// Gets the performance state identification - /// - public PerformanceStateId StateId { get; } - - /// - /// Gets the state index - /// - public int StateIndex { get; } - - /// - /// Gets a list of voltages associated with this performance state - /// - public GPUPerformanceStateVoltage[] Voltages { get; } - - /// - public override string ToString() - { - if (IsReadOnly) - { - return $"{StateId} (ReadOnly)"; - } - - return StateId.ToString(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceStateClock.cs b/app/NvAPIWrapper/GPU/GPUPerformanceStateClock.cs deleted file mode 100644 index e8afe070..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceStateClock.cs +++ /dev/null @@ -1,99 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a performance state clock settings - /// - public class GPUPerformanceStateClock - { - internal GPUPerformanceStateClock(IPerformanceStates20ClockEntry states20ClockEntry) - { - ClockDomain = states20ClockEntry.DomainId; - IsReadOnly = !states20ClockEntry.IsEditable; - ClockDeltaInkHz = states20ClockEntry.FrequencyDeltaInkHz.DeltaValue; - ClockDeltaRangeInkHz = new GPUPerformanceStateValueRange( - states20ClockEntry.FrequencyDeltaInkHz.DeltaRange.Minimum, - states20ClockEntry.FrequencyDeltaInkHz.DeltaRange.Maximum - ); - - if (states20ClockEntry.ClockType == PerformanceStates20ClockType.Range) - { - CurrentClockInkHz = new GPUPerformanceStateValueRange( - states20ClockEntry.FrequencyRange.MinimumFrequencyInkHz, - states20ClockEntry.FrequencyRange.MaximumFrequencyInkHz - ); - BaseClockInkHz = new GPUPerformanceStateValueRange( - CurrentClockInkHz.Minimum - ClockDeltaInkHz, - CurrentClockInkHz.Maximum - ClockDeltaInkHz - ); - DependentVoltageDomain = states20ClockEntry.FrequencyRange.VoltageDomainId; - DependentVoltageRangeInMicroVolt = new GPUPerformanceStateValueRange( - states20ClockEntry.FrequencyRange.MinimumVoltageInMicroVolt, - states20ClockEntry.FrequencyRange.MaximumVoltageInMicroVolt - ); - } - else - { - CurrentClockInkHz = new GPUPerformanceStateValueRange( - states20ClockEntry.SingleFrequency.FrequencyInkHz - ); - BaseClockInkHz = new GPUPerformanceStateValueRange( - CurrentClockInkHz.Minimum - ClockDeltaInkHz - ); - DependentVoltageDomain = PerformanceVoltageDomain.Undefined; - DependentVoltageRangeInMicroVolt = null; - } - } - - /// - /// Gets the base clock frequency in kHz - /// - public GPUPerformanceStateValueRange BaseClockInkHz { get; } - - /// - /// Gets the clock frequency delta in kHz - /// - public int ClockDeltaInkHz { get; } - - /// - /// Gets the clock frequency delta range in kHz - /// - public GPUPerformanceStateValueRange ClockDeltaRangeInkHz { get; } - - /// - /// Gets the clock domain - /// - public PublicClockDomain ClockDomain { get; } - - /// - /// Gets the current clock frequency in kHz - /// - public GPUPerformanceStateValueRange CurrentClockInkHz { get; } - - /// - /// Gets the dependent voltage domain - /// - public PerformanceVoltageDomain DependentVoltageDomain { get; } - - /// - /// Gets the dependent voltage range in uV - /// - public GPUPerformanceStateValueRange DependentVoltageRangeInMicroVolt { get; } - - /// - /// Gets a boolean value indicating if this clock setting is readonly - /// - public bool IsReadOnly { get; } - - /// - public override string ToString() - { - var title = IsReadOnly ? $"{ClockDomain} (ReadOnly)" : ClockDomain.ToString(); - - return - $"{title}: {BaseClockInkHz} + ({ClockDeltaInkHz}) = {CurrentClockInkHz}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceStateValueRange.cs b/app/NvAPIWrapper/GPU/GPUPerformanceStateValueRange.cs deleted file mode 100644 index c3965751..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceStateValueRange.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents an integer value range - /// - public class GPUPerformanceStateValueRange : IEquatable - { - /// - /// Creates a new instance of . - /// - /// The lower bound of the range. - /// The upper bound of the range. - public GPUPerformanceStateValueRange(long min, long max) - { - Minimum = min; - Maximum = max; - } - - /// - /// Creates a new single value instance of . - /// - /// The only value in the range - public GPUPerformanceStateValueRange(long value) - { - Minimum = value; - Maximum = value; - } - - /// - /// Gets the upper bound of the inclusive range - /// - public long Maximum { get; } - - /// - /// Gets the lower bound of the inclusive range - /// - public long Minimum { get; } - - /// - public bool Equals(GPUPerformanceStateValueRange other) - { - if (other == null) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Maximum == other.Maximum && Minimum == other.Minimum; - } - - /// - /// Checks two instances of for equality. - /// - /// The left side of the comparison. - /// The right side of the comparison. - /// true if instances are equal, otherwise false - public static bool operator ==(GPUPerformanceStateValueRange left, GPUPerformanceStateValueRange right) - { - return Equals(left, right) || left?.Equals(right) == true; - } - - /// - /// Checks two instances of for inequality. - /// - /// The left side of the comparison. - /// The right side of the comparison. - /// true if instances are in-equal, otherwise false - public static bool operator !=(GPUPerformanceStateValueRange left, GPUPerformanceStateValueRange right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return Equals(obj as GPUPerformanceStateValueRange); - } - - /// - public override int GetHashCode() - { - unchecked - { - return ((int) Maximum * 397) ^ (int) Minimum; - } - } - - /// - public override string ToString() - { - if (Minimum == Maximum) - { - return $"({Minimum})"; - } - - return $"[({Minimum}) - ({Maximum})]"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceStateVoltage.cs b/app/NvAPIWrapper/GPU/GPUPerformanceStateVoltage.cs deleted file mode 100644 index 97257b9c..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceStateVoltage.cs +++ /dev/null @@ -1,65 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a performance state voltage settings - /// - public class GPUPerformanceStateVoltage - { - internal GPUPerformanceStateVoltage(IPerformanceStates20VoltageEntry states20BaseVoltageEntry) - { - VoltageDomain = states20BaseVoltageEntry.DomainId; - IsReadOnly = !states20BaseVoltageEntry.IsEditable; - - CurrentVoltageInMicroVolt = states20BaseVoltageEntry.ValueInMicroVolt; - VoltageDeltaInMicroVolt = states20BaseVoltageEntry.ValueDeltaInMicroVolt.DeltaValue; - BaseVoltageInMicroVolt = (int) (CurrentVoltageInMicroVolt - VoltageDeltaInMicroVolt); - - VoltageDeltaRangeInMicroVolt = new GPUPerformanceStateValueRange( - states20BaseVoltageEntry.ValueDeltaInMicroVolt.DeltaRange.Minimum, - states20BaseVoltageEntry.ValueDeltaInMicroVolt.DeltaRange.Maximum - ); - } - - /// - /// Gets the base voltage in uV - /// - public int BaseVoltageInMicroVolt { get; } - - /// - /// Gets the current voltage in uV - /// - public uint CurrentVoltageInMicroVolt { get; } - - /// - /// Gets a boolean value indicating if this voltage is readonly - /// - public bool IsReadOnly { get; } - - /// - /// Gets the voltage delta in uV - /// - public int VoltageDeltaInMicroVolt { get; } - - /// - /// Gets the voltage delta range in uV - /// - public GPUPerformanceStateValueRange VoltageDeltaRangeInMicroVolt { get; } - - /// - /// Gets the voltage domain - /// - public PerformanceVoltageDomain VoltageDomain { get; } - - /// - public override string ToString() - { - var title = IsReadOnly ? $"{VoltageDomain} (ReadOnly)" : VoltageDomain.ToString(); - - return - $"{title}: ({BaseVoltageInMicroVolt}) + ({VoltageDeltaInMicroVolt}) = ({CurrentVoltageInMicroVolt})"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPerformanceStatesInfo.cs b/app/NvAPIWrapper/GPU/GPUPerformanceStatesInfo.cs deleted file mode 100644 index 7c267895..00000000 --- a/app/NvAPIWrapper/GPU/GPUPerformanceStatesInfo.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds the retrieved performance states information - /// - public class GPUPerformanceStatesInformation - { - internal GPUPerformanceStatesInformation( - IPerformanceStates20Info states20Info, - PerformanceStateId currentPerformanceStateId, - PrivatePCIeInfoV2? pciInformation) - { - IsReadOnly = !states20Info.IsEditable; - - GlobalVoltages = states20Info.GeneralVoltages - .Select(entry => new GPUPerformanceStateVoltage(entry)) - .ToArray(); - - var clocks = states20Info.Clocks; - var baseVoltages = states20Info.Voltages; - - PerformanceStates = states20Info.PerformanceStates.Select((state20, i) => - { - PCIeInformation statePCIeInfo = null; - - if (pciInformation != null && pciInformation.Value.PCIePerformanceStateInfos.Length > i) - { - statePCIeInfo = new PCIeInformation(pciInformation.Value.PCIePerformanceStateInfos[i]); - } - - return new GPUPerformanceState( - i, - state20, - clocks[state20.StateId], - baseVoltages[state20.StateId], - statePCIeInfo - ); - }).ToArray(); - - CurrentPerformanceState = - PerformanceStates.FirstOrDefault(performanceState => - performanceState.StateId == currentPerformanceStateId); - } - - /// - /// Gets the currently active performance state - /// - public GPUPerformanceState CurrentPerformanceState { get; } - - /// - /// Gets a list of global voltage settings - /// - public GPUPerformanceStateVoltage[] GlobalVoltages { get; } - - /// - /// Gets a boolean value indicating if performance states are readonly - /// - public bool IsReadOnly { get; } - - /// - /// Gets a list of all available performance states - /// - public GPUPerformanceState[] PerformanceStates { get; } - - /// - public override string ToString() - { - if (PerformanceStates.Length == 0) - { - return "No Performance State Available"; - } - - return string.Join( - ", ", - PerformanceStates - .Select( - state => - { - var attributes = new List(); - - if (state.IsReadOnly) - { - attributes.Add("ReadOnly"); - } - - if (CurrentPerformanceState.StateId == state.StateId) - { - attributes.Add("Active"); - } - - if (attributes.Any()) - { - return $"{state.StateId} ({string.Join(" - ", attributes)})"; - } - - return state.StateId.ToString(); - }) - ); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPowerLimitInfo.cs b/app/NvAPIWrapper/GPU/GPUPowerLimitInfo.cs deleted file mode 100644 index 41a01730..00000000 --- a/app/NvAPIWrapper/GPU/GPUPowerLimitInfo.cs +++ /dev/null @@ -1,70 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding a possible power limit policy and its acceptable range - /// - public class GPUPowerLimitInfo - { - internal GPUPowerLimitInfo(PrivatePowerPoliciesInfoV1.PowerPolicyInfoEntry powerPolicyInfoEntry) - { - PerformanceStateId = powerPolicyInfoEntry.PerformanceStateId; - MinimumPowerInPCM = powerPolicyInfoEntry.MinimumPowerInPCM; - DefaultPowerInPCM = powerPolicyInfoEntry.DefaultPowerInPCM; - MaximumPowerInPCM = powerPolicyInfoEntry.MaximumPowerInPCM; - } - - /// - /// Gets the default policy target power in per cent mille (PCM) - /// - public uint DefaultPowerInPCM { get; } - - /// - /// Gets the default policy target power in percentage - /// - public float DefaultPowerInPercent - { - get => DefaultPowerInPCM / 1000f; - } - - /// - /// Gets the maximum possible policy target power in per cent mille (PCM) - /// - public uint MaximumPowerInPCM { get; } - - /// - /// Gets the maximum possible policy target power in percentage - /// - public float MaximumPowerInPercent - { - get => MaximumPowerInPCM / 1000f; - } - - /// - /// Gets the minimum possible policy target power in per cent mille (PCM) - /// - public uint MinimumPowerInPCM { get; } - - /// - /// Gets the minimum possible policy target power in percentage - /// - public float MinimumPowerInPercent - { - get => MinimumPowerInPCM / 1000f; - } - - /// - /// Gets the corresponding performance state identification - /// - public PerformanceStateId PerformanceStateId { get; } - - /// - public override string ToString() - { - return - $"[{PerformanceStateId}] Default: {DefaultPowerInPercent}% - Range: ({MinimumPowerInPercent}% - {MaximumPowerInPercent}%)"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPowerLimitPolicy.cs b/app/NvAPIWrapper/GPU/GPUPowerLimitPolicy.cs deleted file mode 100644 index 3b18cdd6..00000000 --- a/app/NvAPIWrapper/GPU/GPUPowerLimitPolicy.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding a currently active power limit policy - /// - public class GPUPowerLimitPolicy - { - internal GPUPowerLimitPolicy(PrivatePowerPoliciesStatusV1.PowerPolicyStatusEntry powerPolicyStatusEntry) - { - PerformanceStateId = powerPolicyStatusEntry.PerformanceStateId; - PowerTargetInPCM = powerPolicyStatusEntry.PowerTargetInPCM; - } - - /// - /// Gets the corresponding performance state identification - /// - public PerformanceStateId PerformanceStateId { get; } - - /// - /// Gets the current policy target power in per cent mille (PCM) - /// - public uint PowerTargetInPCM { get; } - - /// - /// Gets the current policy target power in percentage - /// - public float PowerTargetInPercent - { - get => PowerTargetInPCM / 1000f; - } - - /// - public override string ToString() - { - return $"{PerformanceStateId} Target: {PowerTargetInPercent}%"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPowerTopologyInformation.cs b/app/NvAPIWrapper/GPU/GPUPowerTopologyInformation.cs deleted file mode 100644 index 9c613850..00000000 --- a/app/NvAPIWrapper/GPU/GPUPowerTopologyInformation.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding current power topology and their current power usage - /// - public class GPUPowerTopologyInformation - { - internal GPUPowerTopologyInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets the current power topology entries - /// - public IEnumerable PowerTopologyEntries - { - get - { - return GPUApi.ClientPowerTopologyGetStatus(PhysicalGPU.Handle).PowerPolicyStatusEntries - .Select(entry => new GPUPowerTopologyStatus(entry)); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUPowerTopologyStatus.cs b/app/NvAPIWrapper/GPU/GPUPowerTopologyStatus.cs deleted file mode 100644 index 54849cad..00000000 --- a/app/NvAPIWrapper/GPU/GPUPowerTopologyStatus.cs +++ /dev/null @@ -1,42 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about a power domain usage - /// - public class GPUPowerTopologyStatus - { - internal GPUPowerTopologyStatus( - PrivatePowerTopologiesStatusV1.PowerTopologiesStatusEntry powerTopologiesStatusEntry) - { - Domain = powerTopologiesStatusEntry.Domain; - PowerUsageInPCM = powerTopologiesStatusEntry.PowerUsageInPCM; - } - - /// - /// Gets the power usage domain - /// - public PowerTopologyDomain Domain { get; } - - /// - /// Gets the current power usage in per cent mille (PCM) - /// - public uint PowerUsageInPCM { get; } - - /// - /// Gets the current power usage in percentage - /// - public float PowerUsageInPercent - { - get => PowerUsageInPCM / 1000f; - } - - /// - public override string ToString() - { - return $"[{Domain}] {PowerUsageInPercent}%"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUThermalInformation.cs b/app/NvAPIWrapper/GPU/GPUThermalInformation.cs deleted file mode 100644 index ea20cb7f..00000000 --- a/app/NvAPIWrapper/GPU/GPUThermalInformation.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding the available thermal sensors and current thermal level of a GPU - /// - public class GPUThermalInformation - { - internal GPUThermalInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the current thermal level of the GPU - /// - public int CurrentThermalLevel - { - get => (int) GPUApi.GetCurrentThermalLevel(PhysicalGPU.Handle); - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets the list of available thermal sensors - /// - public IEnumerable ThermalSensors - { - get - { - return GPUApi.GetThermalSettings(PhysicalGPU.Handle).Sensors - .Select((sensor, i) => new GPUThermalSensor(i, sensor)); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUThermalLimitInfo.cs b/app/NvAPIWrapper/GPU/GPUThermalLimitInfo.cs deleted file mode 100644 index 510c80b4..00000000 --- a/app/NvAPIWrapper/GPU/GPUThermalLimitInfo.cs +++ /dev/null @@ -1,47 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding a possible thermal limit policy and its acceptable range - /// - public class GPUThermalLimitInfo - { - internal GPUThermalLimitInfo(PrivateThermalPoliciesInfoV2.ThermalPoliciesInfoEntry policiesInfoEntry) - { - Controller = policiesInfoEntry.Controller; - MinimumTemperature = policiesInfoEntry.MinimumTemperature; - DefaultTemperature = policiesInfoEntry.DefaultTemperature; - MaximumTemperature = policiesInfoEntry.MaximumTemperature; - } - - /// - /// Gets the policy's thermal controller - /// - public ThermalController Controller { get; } - - /// - /// Gets the default policy target temperature in degree Celsius - /// - public int DefaultTemperature { get; } - - - /// - /// Gets the maximum possible policy target temperature in degree Celsius - /// - public int MaximumTemperature { get; } - - /// - /// Gets the minimum possible policy target temperature in degree Celsius - /// - public int MinimumTemperature { get; } - - /// - public override string ToString() - { - return - $"[{Controller}] Default: {DefaultTemperature}°C - Range: ({MinimumTemperature}°C - {MaximumTemperature}°C)"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUThermalLimitPolicy.cs b/app/NvAPIWrapper/GPU/GPUThermalLimitPolicy.cs deleted file mode 100644 index 9ad502c7..00000000 --- a/app/NvAPIWrapper/GPU/GPUThermalLimitPolicy.cs +++ /dev/null @@ -1,40 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information regarding a currently active temperature limit policy - /// - public class GPUThermalLimitPolicy - { - internal GPUThermalLimitPolicy(PrivateThermalPoliciesStatusV2.ThermalPoliciesStatusEntry thermalPoliciesEntry) - { - Controller = thermalPoliciesEntry.Controller; - PerformanceStateId = thermalPoliciesEntry.PerformanceStateId; - TargetTemperature = thermalPoliciesEntry.TargetTemperature; - } - - /// - /// Gets the policy's thermal controller - /// - public ThermalController Controller { get; } - - /// - /// Gets the corresponding performance state identification - /// - public PerformanceStateId PerformanceStateId { get; } - - /// - /// Gets the current policy target temperature in degree Celsius - /// - public int TargetTemperature { get; } - - /// - public override string ToString() - { - return - $"{PerformanceStateId} [{Controller}] Target: {TargetTemperature}°C"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUThermalSensor.cs b/app/NvAPIWrapper/GPU/GPUThermalSensor.cs deleted file mode 100644 index a1a8c48c..00000000 --- a/app/NvAPIWrapper/GPU/GPUThermalSensor.cs +++ /dev/null @@ -1,48 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a thermal sensor - /// - public class GPUThermalSensor : IThermalSensor - { - internal GPUThermalSensor(int sensorId, IThermalSensor thermalSensor) - { - SensorId = sensorId; - Controller = thermalSensor.Controller; - DefaultMinimumTemperature = thermalSensor.DefaultMinimumTemperature; - DefaultMaximumTemperature = thermalSensor.DefaultMaximumTemperature; - CurrentTemperature = thermalSensor.CurrentTemperature; - Target = thermalSensor.Target; - } - - /// - /// Gets the sensor identification number or index - /// - public int SensorId { get; set; } - - /// - public ThermalController Controller { get; } - - /// - public int CurrentTemperature { get; } - - /// - public int DefaultMaximumTemperature { get; } - - /// - public int DefaultMinimumTemperature { get; } - - /// - public ThermalSettingsTarget Target { get; } - - /// - public override string ToString() - { - return - $"[{Target} @ {Controller}] Current: {CurrentTemperature}°C - Default Range: [({DefaultMinimumTemperature}°C) , ({DefaultMaximumTemperature}°C)]"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUUsageDomainStatus.cs b/app/NvAPIWrapper/GPU/GPUUsageDomainStatus.cs deleted file mode 100644 index 21d4c0f7..00000000 --- a/app/NvAPIWrapper/GPU/GPUUsageDomainStatus.cs +++ /dev/null @@ -1,33 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information about a utilization domain - /// - public class GPUUsageDomainStatus - { - internal GPUUsageDomainStatus(UtilizationDomain domain, IUtilizationDomainInfo utilizationDomainInfo) - { - Domain = domain; - Percentage = (int) utilizationDomainInfo.Percentage; - } - - /// - /// Gets the utilization domain that this instance describes - /// - public UtilizationDomain Domain { get; } - - /// - /// Gets the percentage of time where the domain is considered busy in the last 1 second interval. - /// - public int Percentage { get; } - - /// - public override string ToString() - { - return $"[{Domain}] {Percentage}%"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/GPUUsageInformation.cs b/app/NvAPIWrapper/GPU/GPUUsageInformation.cs deleted file mode 100644 index 1d6b687a..00000000 --- a/app/NvAPIWrapper/GPU/GPUUsageInformation.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Holds information about the GPU utilization domains - /// - public class GPUUsageInformation - { - internal GPUUsageInformation(PhysicalGPU physicalGPU) - { - PhysicalGPU = physicalGPU; - } - - /// - /// Gets the Bus interface (BUS) utilization - /// - public GPUUsageDomainStatus BusInterface - { - get => UtilizationDomainsStatus.FirstOrDefault(status => status.Domain == UtilizationDomain.BusInterface); - } - - /// - /// Gets the frame buffer (FB) utilization - /// - public GPUUsageDomainStatus FrameBuffer - { - get => UtilizationDomainsStatus.FirstOrDefault(status => status.Domain == UtilizationDomain.FrameBuffer); - } - - /// - /// Gets the graphic engine (GPU) utilization - /// - public GPUUsageDomainStatus GPU - { - get => UtilizationDomainsStatus.FirstOrDefault(status => status.Domain == UtilizationDomain.GPU); - } - - /// - /// Gets a boolean value indicating if the dynamic performance states is enabled - /// - public bool IsDynamicPerformanceStatesEnabled - { - get => GPUApi.GetDynamicPerformanceStatesInfoEx(PhysicalGPU.Handle).IsDynamicPerformanceStatesEnabled; - } - - /// - /// Gets the physical GPU that this instance describes - /// - public PhysicalGPU PhysicalGPU { get; } - - /// - /// Gets all valid utilization domains and information - /// - public IEnumerable UtilizationDomainsStatus - { - get - { - try - { - var dynamicPerformanceStates = GPUApi.GetDynamicPerformanceStatesInfoEx(PhysicalGPU.Handle); - - if (dynamicPerformanceStates.IsDynamicPerformanceStatesEnabled) - { - return dynamicPerformanceStates.Domains - .Select(pair => new GPUUsageDomainStatus(pair.Key, pair.Value)); - } - } - catch - { - // ignored - } - - return GPUApi.GetUsages(PhysicalGPU.Handle).Domains - .Select(pair => new GPUUsageDomainStatus(pair.Key, pair.Value)); - } - } - - - /// - /// Gets the Video engine (VID) utilization - /// - public GPUUsageDomainStatus VideoEngine - { - get => UtilizationDomainsStatus.FirstOrDefault(status => status.Domain == UtilizationDomain.VideoEngine); - } - - /// - /// Enables dynamic performance states - /// - public void EnableDynamicPerformanceStates() - { - GPUApi.EnableDynamicPStates(PhysicalGPU.Handle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/LogicalGPU.cs b/app/NvAPIWrapper/GPU/LogicalGPU.cs deleted file mode 100644 index 6f156666..00000000 --- a/app/NvAPIWrapper/GPU/LogicalGPU.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a logical NVIDIA GPU - /// - public class LogicalGPU : IEquatable - { - /// - /// Creates a new LogicalGPU - /// - /// Logical GPU handle - public LogicalGPU(LogicalGPUHandle handle) - { - Handle = handle; - } - - /// - /// Gets a list of all corresponding physical GPUs - /// - public PhysicalGPU[] CorrespondingPhysicalGPUs - { - get - { - return GPUApi.GetPhysicalGPUsFromLogicalGPU(Handle).Select(handle => new PhysicalGPU(handle)).ToArray(); - } - } - - /// - /// Gets the logical GPU handle - /// - public LogicalGPUHandle Handle { get; } - - /// - public bool Equals(LogicalGPU other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Handle.Equals(other.Handle); - } - - /// - /// Gets all logical GPUs - /// - /// An array of logical GPUs - public static LogicalGPU[] GetLogicalGPUs() - { - return GPUApi.EnumLogicalGPUs().Select(handle => new LogicalGPU(handle)).ToArray(); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(LogicalGPU left, LogicalGPU right) - { - return right?.Equals(left) ?? ReferenceEquals(left, null); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(LogicalGPU left, LogicalGPU right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != GetType()) - { - return false; - } - - return Equals((LogicalGPU) obj); - } - - /// - public override int GetHashCode() - { - return Handle.GetHashCode(); - } - - /// - public override string ToString() - { - return - $"Logical GPU [{CorrespondingPhysicalGPUs.Length}] {{{string.Join(", ", CorrespondingPhysicalGPUs.Select(gpu => gpu.FullName).ToArray())}}}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/PCIIdentifiers.cs b/app/NvAPIWrapper/GPU/PCIIdentifiers.cs deleted file mode 100644 index 0076a861..00000000 --- a/app/NvAPIWrapper/GPU/PCIIdentifiers.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the PCI connection - /// - public class PCIIdentifiers : IEquatable - { - // ReSharper disable once TooManyDependencies - internal PCIIdentifiers(uint deviceId, uint subSystemId, uint revisionId, int externalDeviceId = 0) - { - DeviceId = deviceId; - SubSystemId = subSystemId; - RevisionId = revisionId; - - if (externalDeviceId > 0) - { - ExternalDeviceId = (ushort) externalDeviceId; - } - else - { - ExternalDeviceId = (ushort) (deviceId >> 16); - } - - VendorId = (ushort) ((DeviceId << 16) >> 16); - } - - /// - /// Gets the internal PCI device identifier - /// - public uint DeviceId { get; } - - /// - /// Gets the external PCI device identifier - /// - public ushort ExternalDeviceId { get; } - - /// - /// Gets the internal PCI device-specific revision identifier - /// - public uint RevisionId { get; } - - /// - /// Gets the internal PCI subsystem identifier - /// - public uint SubSystemId { get; } - - /// - /// Gets the vendor identification calculated from internal device identification - /// - public ushort VendorId { get; } - - /// - public bool Equals(PCIIdentifiers other) - { - return DeviceId == other.DeviceId && - SubSystemId == other.SubSystemId && - RevisionId == other.RevisionId; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(PCIIdentifiers left, PCIIdentifiers right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(PCIIdentifiers left, PCIIdentifiers right) - { - return !left.Equals(right); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PCIIdentifiers identifiers && Equals(identifiers); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) DeviceId; - hashCode = (hashCode * 397) ^ (int) SubSystemId; - hashCode = (hashCode * 397) ^ (int) RevisionId; - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"PCI\\VEN_{VendorId:X}&DEV_{ExternalDeviceId:X}&SUBSYS_{SubSystemId:X}&REV_{RevisionId:X}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/PCIeInformation.cs b/app/NvAPIWrapper/GPU/PCIeInformation.cs deleted file mode 100644 index b5855776..00000000 --- a/app/NvAPIWrapper/GPU/PCIeInformation.cs +++ /dev/null @@ -1,67 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the PCI-e connection - /// - public class PCIeInformation - { - internal PCIeInformation(PrivatePCIeInfoV2.PCIePerformanceStateInfo stateInfo) - { - TransferRateInMTps = stateInfo.TransferRateInMTps; - Generation = stateInfo.Generation; - Lanes = stateInfo.Lanes; - Version = stateInfo.Version; - } - - /// - /// Gets the PCI-e generation - /// - public PCIeGeneration Generation { get; } - - /// - /// Gets the PCI-e down stream lanes - /// - public uint Lanes { get; } - - /// - /// Gets the PCIe transfer rate in Mega Transfers per Second - /// - public uint TransferRateInMTps { get; } - - /// - /// Gets the PCI-e version - /// - public PCIeGeneration Version { get; } - - /// - public override string ToString() - { - var v = "Unknown"; - - switch (Version) - { - case PCIeGeneration.PCIe1: - v = "PCIe 1.0"; - - break; - case PCIeGeneration.PCIe1Minor1: - v = "PCIe 1.1"; - - break; - case PCIeGeneration.PCIe2: - v = "PCIe 2.0"; - - break; - case PCIeGeneration.PCIe3: - v = "PCIe 3.0"; - - break; - } - - return $"{v} x{Lanes} - {TransferRateInMTps} MTps"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/PhysicalGPU.cs b/app/NvAPIWrapper/GPU/PhysicalGPU.cs deleted file mode 100644 index cb8f62a3..00000000 --- a/app/NvAPIWrapper/GPU/PhysicalGPU.cs +++ /dev/null @@ -1,559 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using NvAPIWrapper.Display; -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.GPU -{ - /// - /// Represents a physical NVIDIA GPU - /// - public class PhysicalGPU : IEquatable - { - /// - /// Creates a new PhysicalGPU - /// - /// Physical GPU handle - public PhysicalGPU(PhysicalGPUHandle handle) - { - Handle = handle; - UsageInformation = new GPUUsageInformation(this); - ThermalInformation = new GPUThermalInformation(this); - BusInformation = new GPUBusInformation(this); - ArchitectInformation = new GPUArchitectInformation(this); - MemoryInformation = new GPUMemoryInformation(this); - CoolerInformation = new GPUCoolerInformation(this); - ECCMemoryInformation = new ECCMemoryInformation(this); - PerformanceControl = new GPUPerformanceControl(this); - PowerTopologyInformation = new GPUPowerTopologyInformation(this); - } - - /// - /// Gets all active outputs of this GPU - /// - public GPUOutput[] ActiveOutputs - { - get - { - var outputs = new List(); - var allOutputs = GPUApi.GetActiveOutputs(Handle); - - foreach (OutputId outputId in Enum.GetValues(typeof(OutputId))) - { - if (outputId != OutputId.Invalid && allOutputs.HasFlag(outputId)) - { - outputs.Add(new GPUOutput(outputId, this)); - } - } - - return outputs.ToArray(); - } - } - - /// - /// Gets GPU architect information - /// - public GPUArchitectInformation ArchitectInformation { get; } - - /// - /// Gets GPU base clock frequencies - /// - public IClockFrequencies BaseClockFrequencies - { - get => GPUApi.GetAllClockFrequencies(Handle, new ClockFrequenciesV2(ClockType.BaseClock)); - } - - /// - /// Gets GPU video BIOS information - /// - public VideoBIOS Bios - { - get => new VideoBIOS( - GPUApi.GetVBIOSRevision(Handle), - (int) GPUApi.GetVBIOSOEMRevision(Handle), - GPUApi.GetVBIOSVersionString(Handle) - ); - } - - /// - /// Gets the board information - /// - public BoardInfo Board - { - get - { - try - { - return GPUApi.GetBoardInfo(Handle); - } - catch (NVIDIAApiException ex) - { - if (ex.Status == Status.NotSupported) - { - return default; - } - - throw; - } - } - } - - /// - /// Gets GPU boost clock frequencies - /// - public IClockFrequencies BoostClockFrequencies - { - get => GPUApi.GetAllClockFrequencies(Handle, new ClockFrequenciesV2(ClockType.BoostClock)); - } - - /// - /// Gets GPU bus information - /// - public GPUBusInformation BusInformation { get; } - - /// - /// Gets GPU coolers information - /// - public GPUCoolerInformation CoolerInformation { get; } - - /// - /// Gets corresponding logical GPU - /// - public LogicalGPU CorrespondingLogicalGPU - { - get => new LogicalGPU(GPUApi.GetLogicalGPUFromPhysicalGPU(Handle)); - } - - /// - /// Gets GPU current clock frequencies - /// - public IClockFrequencies CurrentClockFrequencies - { - get => GPUApi.GetAllClockFrequencies(Handle, new ClockFrequenciesV2(ClockType.CurrentClock)); - } - - /// - /// Gets the driver model number for this GPU - /// - public uint DriverModel - { - get => GPUApi.GetDriverModel(Handle); - } - - /// - /// Gets GPU ECC memory information - /// - public ECCMemoryInformation ECCMemoryInformation { get; } - - /// - /// Gets the chipset foundry - /// - public GPUFoundry Foundry - { - get => GPUApi.GetFoundry(Handle); - } - - /// - /// Gets GPU full name - /// - public string FullName - { - get => GPUApi.GetFullName(Handle); - } - - /// - /// Gets the GPU identification number - /// - public uint GPUId - { - get => GPUApi.GetGPUIDFromPhysicalGPU(Handle); - } - - /// - /// Gets GPU type - /// - public GPUType GPUType - { - get => GPUApi.GetGPUType(Handle); - } - - /// - /// Gets the physical GPU handle - /// - public PhysicalGPUHandle Handle { get; } - - /// - /// Gets a boolean value indicating the Quadro line of products - /// - public bool IsQuadro - { - get => GPUApi.GetQuadroStatus(Handle); - } - - /// - /// Gets GPU memory and RAM information as well as frame-buffer information - /// - public GPUMemoryInformation MemoryInformation { get; } - - /// - /// Gets GPU performance control status and configurations - /// - public GPUPerformanceControl PerformanceControl { get; } - - - /// - /// Gets the GPU performance states information and configurations - /// - public GPUPerformanceStatesInformation PerformanceStatesInfo - { - get - { - var performanceStates20Info = GPUApi.GetPerformanceStates20(Handle); - var currentPerformanceState = GPUApi.GetCurrentPerformanceState(Handle); - PrivatePCIeInfoV2? pcieInformation = null; - - if (BusInformation.BusType == GPUBusType.PCIExpress) - { - try - { - pcieInformation = GPUApi.GetPCIEInfo(Handle); - } - catch - { - // ignore - } - } - - return new GPUPerformanceStatesInformation(performanceStates20Info, currentPerformanceState, - pcieInformation); - } - } - - /// - /// Gets GPU coolers information - /// - public GPUPowerTopologyInformation PowerTopologyInformation { get; } - - /// - /// Gets GPU system type - /// - public SystemType SystemType - { - get => GPUApi.GetSystemType(Handle); - } - - /// - /// Gets GPU thermal sensors information - /// - public GPUThermalInformation ThermalInformation { get; } - - /// - /// Gets the GPU utilization domains and usages - /// - public GPUUsageInformation UsageInformation { get; } - - /// - public bool Equals(PhysicalGPU other) - { - if (other == null) - { - return false; - } - - if (ReferenceEquals(this, other)) - { - return true; - } - - return Handle.Equals(other.Handle); - } - - /// - /// Gets the corresponding instance from a GPU identification number. - /// - /// The GPU identification number. - /// An instance of or if operation failed. - public static PhysicalGPU FromGPUId(uint gpuId) - { - var handle = GPUApi.GetPhysicalGPUFromGPUID(gpuId); - - if (handle.IsNull) - { - return null; - } - - return new PhysicalGPU(handle); - } - - /// - /// Gets all physical GPUs - /// - /// An array of physical GPUs - public static PhysicalGPU[] GetPhysicalGPUs() - { - return GPUApi.EnumPhysicalGPUs().Select(handle => new PhysicalGPU(handle)).ToArray(); - } - - /// - /// Gets all physical GPUs in TCC state - /// - /// An array of physical GPUs - public static PhysicalGPU[] GetTCCPhysicalGPUs() - { - return GPUApi.EnumTCCPhysicalGPUs().Select(handle => new PhysicalGPU(handle)).ToArray(); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(PhysicalGPU left, PhysicalGPU right) - { - return Equals(left, right) || left?.Equals(right) == true; - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(PhysicalGPU left, PhysicalGPU right) - { - return !(left == right); - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - return Equals(obj as PhysicalGPU); - } - - /// - public override int GetHashCode() - { - return Handle.GetHashCode(); - } - - /// - public override string ToString() - { - return FullName; - } - - /// - /// Get a list of all active applications for this GPU - /// - /// An array of processes - public Process[] GetActiveApplications() - { - return GPUApi.QueryActiveApps(Handle).Select(app => Process.GetProcessById(app.ProcessId)).ToArray(); - } - - /// - /// Get a list of all connected display devices on this GPU - /// - /// ConnectedIdsFlag flag - /// An array of display devices - public DisplayDevice[] GetConnectedDisplayDevices(ConnectedIdsFlag flags) - { - return GPUApi.GetConnectedDisplayIds(Handle, flags).Select(display => new DisplayDevice(display)).ToArray(); - } - - /// - /// Get the display device connected to a specific GPU output - /// - /// The GPU output to get connected display device for - /// DisplayDevice connected to the specified GPU output - public DisplayDevice GetDisplayDeviceByOutput(GPUOutput output) - { - return new DisplayDevice(GPUApi.GetDisplayIdFromGPUAndOutputId(Handle, output.OutputId)); - } - - /// - /// Get a list of all display devices on any possible output - /// - /// An array of display devices - public DisplayDevice[] GetDisplayDevices() - { - return GPUApi.GetAllDisplayIds(Handle).Select(display => new DisplayDevice(display)).ToArray(); - } - - /// - /// Reads EDID data of an output - /// - /// The GPU output to read EDID information for - /// A byte array containing EDID data - public byte[] ReadEDIDData(GPUOutput output) - { - try - { - var data = new byte[0]; - var identification = 0; - var totalSize = EDIDV3.MaxDataSize; - - for (var offset = 0; offset < totalSize; offset += EDIDV3.MaxDataSize) - { - var edid = GPUApi.GetEDID(Handle, output.OutputId, offset, identification); - identification = edid.Identification; - totalSize = edid.TotalSize; - - var edidData = edid.Data; - Array.Resize(ref data, data.Length + edidData.Length); - Array.Copy(edidData, 0, data, data.Length - edidData.Length, edidData.Length); - } - - return data; - } - catch (NVIDIAApiException ex) - { - if (ex.Status == Status.IncompatibleStructureVersion) - { - return GPUApi.GetEDID(Handle, output.OutputId).Data; - } - - throw; - } - } - - /// - /// Reads data from the I2C bus - /// - /// Information required to read from the I2C bus. - /// The returned payload. - // ReSharper disable once InconsistentNaming - public byte[] ReadI2C(II2CInfo i2cInfo) - { - GPUApi.I2CRead(Handle, ref i2cInfo); - - return i2cInfo.Data; - } - - /// - /// Validates a set of GPU outputs to check if they can be active simultaneously - /// - /// GPU outputs to check - /// true if all specified outputs can be active simultaneously, otherwise false - public bool ValidateOutputCombination(GPUOutput[] outputs) - { - var gpuOutpudIds = - outputs.Aggregate(OutputId.Invalid, (current, gpuOutput) => current | gpuOutput.OutputId); - - return GPUApi.ValidateOutputCombination(Handle, gpuOutpudIds); - } - - /// - /// Writes EDID data of an output - /// - /// The GPU output to write EDID information for - /// A byte array containing EDID data - public void WriteEDIDData(GPUOutput output, byte[] edidData) - { - WriteEDIDData((uint) output.OutputId, edidData); - } - - /// - /// Writes EDID data of an display - /// - /// The display device to write EDID information for - /// A byte array containing EDID data - public void WriteEDIDData(DisplayDevice display, byte[] edidData) - { - WriteEDIDData(display.DisplayId, edidData); - } - - /// - /// Writes data to the I2C bus - /// - /// Information required to write to the I2C bus including data payload. - // ReSharper disable once InconsistentNaming - public void WriteI2C(II2CInfo i2cInfo) - { - GPUApi.I2CWrite(Handle, i2cInfo); - } - - private void WriteEDIDData(uint displayOutputId, byte[] edidData) - { - try - { - if (edidData.Length == 0) - { - var instance = typeof(EDIDV3).Instantiate(); - GPUApi.SetEDID(Handle, displayOutputId, instance); - } - - for (var offset = 0; offset < edidData.Length; offset += EDIDV3.MaxDataSize) - { - var array = new byte[Math.Min(EDIDV3.MaxDataSize, edidData.Length - offset)]; - Array.Copy(edidData, offset, array, 0, array.Length); - var instance = EDIDV3.CreateWithData(0, (uint) offset, array, edidData.Length); - GPUApi.SetEDID(Handle, displayOutputId, instance); - } - - return; - } - catch (NVIDIAApiException ex) - { - if (ex.Status != Status.IncompatibleStructureVersion) - { - throw; - } - } - catch (NVIDIANotSupportedException) - { - // ignore - } - - try - { - if (edidData.Length == 0) - { - var instance = typeof(EDIDV2).Instantiate(); - GPUApi.SetEDID(Handle, displayOutputId, instance); - } - - for (var offset = 0; offset < edidData.Length; offset += EDIDV2.MaxDataSize) - { - var array = new byte[Math.Min(EDIDV2.MaxDataSize, edidData.Length - offset)]; - Array.Copy(edidData, offset, array, 0, array.Length); - GPUApi.SetEDID(Handle, displayOutputId, EDIDV2.CreateWithData(array, edidData.Length)); - } - - return; - } - catch (NVIDIAApiException ex) - { - if (ex.Status != Status.IncompatibleStructureVersion) - { - throw; - } - } - catch (NVIDIANotSupportedException) - { - // ignore - } - - GPUApi.SetEDID(Handle, displayOutputId, EDIDV1.CreateWithData(edidData)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/GPU/VideoBIOS.cs b/app/NvAPIWrapper/GPU/VideoBIOS.cs deleted file mode 100644 index 72b522da..00000000 --- a/app/NvAPIWrapper/GPU/VideoBIOS.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; - -namespace NvAPIWrapper.GPU -{ - /// - /// Contains information about the GPU Video BIOS - /// - public class VideoBIOS - { - internal VideoBIOS(uint revision, int oemRevision, string versionString) - { - Revision = revision; - OEMRevision = oemRevision; - VersionString = versionString.ToUpper(); - } - - /// - /// Gets the the OEM revision of the video BIOS - /// - public int OEMRevision { get; } - - /// - /// Gets the revision of the video BIOS - /// - public uint Revision { get; } - - /// - /// Gets the full video BIOS version string - /// - public string VersionString { get; } - - /// - public override string ToString() - { - return AsVersion().ToString(); - } - - /// - /// Returns the video BIOS version as a .Net Version object - /// - /// A Version object representing the video BIOS version - public Version AsVersion() - { - return new Version( - (int) ((Revision >> 28) + ((Revision << 4) >> 28) * 16), // 8 bit little endian - (int) (((Revision << 8) >> 28) + ((Revision << 12) >> 28) * 16), // 8 bit little endian - (int) ((Revision << 16) >> 16), // 16 bit big endian - OEMRevision // 8 bit integer - ); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Icon.png b/app/NvAPIWrapper/Icon.png deleted file mode 100644 index 43914ecd..00000000 Binary files a/app/NvAPIWrapper/Icon.png and /dev/null differ diff --git a/app/NvAPIWrapper/NVIDIA.cs b/app/NvAPIWrapper/NVIDIA.cs deleted file mode 100644 index 5fd58255..00000000 --- a/app/NvAPIWrapper/NVIDIA.cs +++ /dev/null @@ -1,81 +0,0 @@ -using NvAPIWrapper.Native; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper -{ - /// - /// .Net friendly version of system and general functions of NVAPI library - /// - public static class NVIDIA - { - /// - /// Gets information about the system's chipset. - /// - public static IChipsetInfo ChipsetInfo - { - get => GeneralApi.GetChipsetInfo(); - } - - /// - /// Gets NVIDIA driver branch version as string - /// - public static string DriverBranchVersion - { - get - { - GeneralApi.GetDriverAndBranchVersion(out var branchVersion); - - return branchVersion; - } - } - - /// - /// Gets NVIDIA driver version - /// - public static uint DriverVersion - { - get => GeneralApi.GetDriverAndBranchVersion(out _); - } - - /// - /// Gets NVAPI interface version as string - /// - public static string InterfaceVersionString - { - get => GeneralApi.GetInterfaceVersionString(); - } - - /// - /// Gets the current lid and dock information. - /// - public static LidDockParameters LidAndDockParameters - { - get => GeneralApi.GetLidAndDockInfo(); - } - - /// - /// Initializes the NvAPI library (if not already initialized) but always increments the ref-counter. - /// - public static void Initialize() - { - GeneralApi.Initialize(); - } - - /// - /// PRIVATE - Requests to restart the display driver - /// - public static void RestartDisplayDriver() - { - GeneralApi.RestartDisplayDriver(); - } - - /// - /// Decrements the ref-counter and when it reaches ZERO, unloads NVAPI library. - /// - public static void Unload() - { - GeneralApi.Unload(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Attributes/AcceptsAttribute.cs b/app/NvAPIWrapper/Native/Attributes/AcceptsAttribute.cs deleted file mode 100644 index 7df15fbb..00000000 --- a/app/NvAPIWrapper/Native/Attributes/AcceptsAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Attributes -{ - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Delegate)] - internal class AcceptsAttribute : Attribute - { - public AcceptsAttribute(params Type[] types) - { - Types = types; - } - - public Type[] Types { get; set; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Attributes/FunctionIdAttribute.cs b/app/NvAPIWrapper/Native/Attributes/FunctionIdAttribute.cs deleted file mode 100644 index 260da7d3..00000000 --- a/app/NvAPIWrapper/Native/Attributes/FunctionIdAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Attributes -{ - [AttributeUsage(AttributeTargets.Delegate)] - internal class FunctionIdAttribute : Attribute - { - public FunctionIdAttribute(FunctionId functionId) - { - FunctionId = functionId; - } - - public FunctionId FunctionId { get; set; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Attributes/StructureVersionAttribute.cs b/app/NvAPIWrapper/Native/Attributes/StructureVersionAttribute.cs deleted file mode 100644 index 9752e65c..00000000 --- a/app/NvAPIWrapper/Native/Attributes/StructureVersionAttribute.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Attributes -{ - [AttributeUsage(AttributeTargets.Struct)] - internal class StructureVersionAttribute : Attribute - { - public StructureVersionAttribute() - { - } - - public StructureVersionAttribute(int versionNumber) - { - VersionNumber = versionNumber; - } - - public int VersionNumber { get; set; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Constants/Display.cs b/app/NvAPIWrapper/Native/Constants/Display.cs deleted file mode 100644 index c7a01b81..00000000 --- a/app/NvAPIWrapper/Native/Constants/Display.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NvAPIWrapper.Native.Constants -{ - internal static class Display - { - public const int AdvancedDisplayHeads = 4; - public const int MaxDisplayHeads = 2; - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Constants/General.cs b/app/NvAPIWrapper/Native/Constants/General.cs deleted file mode 100644 index 20468c7e..00000000 --- a/app/NvAPIWrapper/Native/Constants/General.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NvAPIWrapper.Native.Constants -{ - internal static class General - { - public const int BinaryDataMax = 4096; - public const int UnicodeStringLength = 2048; - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/DRSSettingLocation.cs b/app/NvAPIWrapper/Native/DRS/DRSSettingLocation.cs deleted file mode 100644 index 27f9a24d..00000000 --- a/app/NvAPIWrapper/Native/DRS/DRSSettingLocation.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.DRS -{ - /// - /// Holds possible values for the setting location - /// - public enum DRSSettingLocation : uint - { - /// - /// Setting is part of the current profile - /// - CurrentProfile = 0, - - /// - /// Setting is part of the global profile - /// - GlobalProfile, - - /// - /// Setting is part of the base profile - /// - BaseProfile, - - /// - /// Setting is part of the default profile - /// - DefaultProfile - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/DRSSettingType.cs b/app/NvAPIWrapper/Native/DRS/DRSSettingType.cs deleted file mode 100644 index 4fc45d0b..00000000 --- a/app/NvAPIWrapper/Native/DRS/DRSSettingType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.DRS -{ - /// - /// Holds a list of possible setting value types - /// - public enum DRSSettingType : uint - { - /// - /// Integer value type - /// - Integer = 0, - - /// - /// Binary value type - /// - Binary, - - /// - /// ASCII string value type - /// - String, - - /// - /// Unicode string value type - /// - UnicodeString - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV1.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV1.cs deleted file mode 100644 index 0371374e..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV1.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.DRS; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DRSApplicationV1 : IInitializable, IDRSApplication - { - internal StructureVersion _Version; - internal uint _IsPredefined; - internal UnicodeString _ApplicationName; - internal UnicodeString _FriendlyName; - internal UnicodeString _LauncherName; - - /// - /// Creates a new instance of - /// - /// The application file name. - /// The application friendly name. - /// The application launcher name. - public DRSApplicationV1( - string applicationName, - string friendlyName = null, - string launcherName = null - ) - { - this = typeof(DRSApplicationV1).Instantiate(); - IsPredefined = false; - ApplicationName = applicationName; - FriendlyName = friendlyName ?? string.Empty; - LauncherName = launcherName ?? string.Empty; - } - - /// - public bool IsPredefined - { - get => _IsPredefined > 0; - private set => _IsPredefined = value ? 1u : 0u; - } - - /// - public string ApplicationName - { - get => _ApplicationName.Value; - private set - { - if (string.IsNullOrEmpty(value)) - { - throw new ArgumentException("Name can not be empty or null."); - } - - _ApplicationName = new UnicodeString(value); - } - } - - /// - public string FriendlyName - { - get => _FriendlyName.Value; - private set => _FriendlyName = new UnicodeString(value); - } - - /// - public string LauncherName - { - get => _LauncherName.Value; - private set => _LauncherName = new UnicodeString(value); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV2.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV2.cs deleted file mode 100644 index ee3e8c32..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV2.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.DRS; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct DRSApplicationV2 : IInitializable, IDRSApplication - { - internal const char FileInFolderSeparator = ':'; - internal StructureVersion _Version; - internal uint _IsPredefined; - internal UnicodeString _ApplicationName; - internal UnicodeString _FriendlyName; - internal UnicodeString _LauncherName; - internal UnicodeString _FileInFolder; - - /// - /// Creates a new instance of - /// - /// The application file name. - /// The application friendly name. - /// The application launcher name. - /// The list of files that are necessary to be present in the application parent directory. - // ReSharper disable once TooManyDependencies - public DRSApplicationV2( - string applicationName, - string friendlyName = null, - string launcherName = null, - string[] fileInFolders = null - ) - { - this = typeof(DRSApplicationV2).Instantiate(); - IsPredefined = false; - ApplicationName = applicationName; - FriendlyName = friendlyName ?? string.Empty; - LauncherName = launcherName ?? string.Empty; - FilesInFolder = fileInFolders ?? new string[0]; - } - - /// - public bool IsPredefined - { - get => _IsPredefined > 0; - private set => _IsPredefined = value ? 1u : 0u; - } - - /// - public string ApplicationName - { - get => _ApplicationName.Value; - private set - { - if (string.IsNullOrEmpty(value)) - { - throw new ArgumentException("Name can not be empty or null."); - } - - _ApplicationName = new UnicodeString(value); - } - } - - /// - public string FriendlyName - { - get => _FriendlyName.Value; - private set => _FriendlyName = new UnicodeString(value); - } - - /// - public string LauncherName - { - get => _LauncherName.Value; - private set => _LauncherName = new UnicodeString(value); - } - - /// - /// Gets the list of files that are necessary to be present in the application parent directory. - /// - public string[] FilesInFolder - { - get => _FileInFolder.Value?.Split(new[] {FileInFolderSeparator}, StringSplitOptions.RemoveEmptyEntries) ?? - new string[0]; - private set => _FileInFolder = new UnicodeString(string.Join(FileInFolderSeparator.ToString(), value)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV3.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV3.cs deleted file mode 100644 index 207649ea..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV3.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.DRS; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct DRSApplicationV3 : IInitializable, IDRSApplication - { - internal const char FileInFolderSeparator = DRSApplicationV2.FileInFolderSeparator; - internal StructureVersion _Version; - internal uint _IsPredefined; - internal UnicodeString _ApplicationName; - internal UnicodeString _FriendlyName; - internal UnicodeString _LauncherName; - internal UnicodeString _FileInFolder; - internal uint _Flags; - - /// - /// Creates a new instance of - /// - /// The application file name. - /// The application friendly name. - /// The application launcher name. - /// The list of files that are necessary to be present in the application parent directory. - /// A boolean value indicating if this application is a metro application. - // ReSharper disable once TooManyDependencies - public DRSApplicationV3( - string applicationName, - string friendlyName = null, - string launcherName = null, - string[] fileInFolders = null, - bool isMetro = false - ) - { - this = typeof(DRSApplicationV3).Instantiate(); - IsPredefined = false; - ApplicationName = applicationName; - FriendlyName = friendlyName ?? string.Empty; - LauncherName = launcherName ?? string.Empty; - FilesInFolder = fileInFolders ?? new string[0]; - IsMetroApplication = isMetro; - } - - /// - public bool IsPredefined - { - get => _IsPredefined > 0; - private set => _IsPredefined = value ? 1u : 0u; - } - - /// - /// Gets a boolean value indicating if this application is a metro application - /// - public bool IsMetroApplication - { - get => _Flags.GetBit(0); - private set => _Flags = _Flags.SetBit(0, value); - } - - /// - /// Gets a boolean value indicating if this application has command line arguments - /// - public bool HasCommandLine - { - get => _Flags.GetBit(1); - } - - /// - public string ApplicationName - { - get => _ApplicationName.Value; - private set - { - if (string.IsNullOrEmpty(value)) - { - throw new ArgumentException("Name can not be empty or null."); - } - - _ApplicationName = new UnicodeString(value); - } - } - - /// - public string FriendlyName - { - get => _FriendlyName.Value; - private set => _FriendlyName = new UnicodeString(value); - } - - /// - public string LauncherName - { - get => _LauncherName.Value; - private set => _LauncherName = new UnicodeString(value); - } - - /// - /// Gets the list of files that are necessary to be present in the application parent directory. - /// - public string[] FilesInFolder - { - get => _FileInFolder.Value?.Split(new[] {FileInFolderSeparator}, StringSplitOptions.RemoveEmptyEntries) ?? - new string[0]; - private set => _FileInFolder = new UnicodeString(string.Join(FileInFolderSeparator.ToString(), value)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV4.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV4.cs deleted file mode 100644 index debc302e..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSApplicationV4.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.DRS; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(4)] - public struct DRSApplicationV4 : IInitializable, IDRSApplication - { - internal const char FileInFolderSeparator = DRSApplicationV3.FileInFolderSeparator; - internal StructureVersion _Version; - internal uint _IsPredefined; - internal UnicodeString _ApplicationName; - internal UnicodeString _FriendlyName; - internal UnicodeString _LauncherName; - internal UnicodeString _FileInFolder; - internal uint _Flags; - internal UnicodeString _CommandLine; - - /// - /// Creates a new instance of - /// - /// The application file name. - /// The application friendly name. - /// The application launcher name. - /// The list of files that are necessary to be present in the application parent directory. - /// A boolean value indicating if this application is a metro application. - /// The application's command line arguments. - // ReSharper disable once TooManyDependencies - public DRSApplicationV4( - string applicationName, - string friendlyName = null, - string launcherName = null, - string[] fileInFolders = null, - bool isMetro = false, - string commandLine = null - ) - { - this = typeof(DRSApplicationV4).Instantiate(); - IsPredefined = false; - ApplicationName = applicationName; - FriendlyName = friendlyName ?? string.Empty; - LauncherName = launcherName ?? string.Empty; - FilesInFolder = fileInFolders ?? new string[0]; - IsMetroApplication = isMetro; - ApplicationCommandLine = commandLine ?? string.Empty; - } - - /// - public bool IsPredefined - { - get => _IsPredefined > 0; - private set => _IsPredefined = value ? 1u : 0u; - } - - /// - /// Gets a boolean value indicating if this application is a metro application - /// - public bool IsMetroApplication - { - get => _Flags.GetBit(0); - private set => _Flags = _Flags.SetBit(0, value); - } - - /// - /// Gets a boolean value indicating if this application has command line arguments - /// - public bool HasCommandLine - { - get => _Flags.GetBit(1); - private set => _Flags = _Flags.SetBit(1, value); - } - - /// - public string ApplicationName - { - get => _ApplicationName.Value; - private set - { - if (string.IsNullOrEmpty(value)) - { - throw new ArgumentException("Name can not be empty or null."); - } - - _ApplicationName = new UnicodeString(value); - } - } - - /// - /// Gets the application command line arguments - /// - public string ApplicationCommandLine - { - get => (HasCommandLine ? _CommandLine.Value : null) ?? string.Empty; - private set - { - if (string.IsNullOrEmpty(value)) - { - _CommandLine = new UnicodeString(null); - - if (HasCommandLine) - { - HasCommandLine = false; - } - } - else - { - _CommandLine = new UnicodeString(value); - - if (!HasCommandLine) - { - HasCommandLine = true; - } - } - } - } - - /// - public string FriendlyName - { - get => _FriendlyName.Value; - private set => _FriendlyName = new UnicodeString(value); - } - - /// - public string LauncherName - { - get => _LauncherName.Value; - private set => _LauncherName = new UnicodeString(value); - } - - /// - /// Gets the list of files that are necessary to be present in the application parent directory. - /// - public string[] FilesInFolder - { - get => _FileInFolder.Value?.Split(new[] {FileInFolderSeparator}, StringSplitOptions.RemoveEmptyEntries) ?? - new string[0]; - private set => _FileInFolder = new UnicodeString(string.Join(FileInFolderSeparator.ToString(), value)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSGPUSupport.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSGPUSupport.cs deleted file mode 100644 index d229eb86..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSGPUSupport.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// Contains a list of supported GPU series by a NVIDIA driver setting profile - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct DRSGPUSupport - { - internal uint _Flags; - - /// - /// Gets or sets a value indicating if the GeForce line of products are supported - /// - public bool IsGeForceSupported - { - get => _Flags.GetBit(0); - set => _Flags = _Flags.SetBit(0, value); - } - - /// - /// Gets or sets a value indicating if the Quadro line of products are supported - /// - public bool IsQuadroSupported - { - get => _Flags.GetBit(1); - set => _Flags = _Flags.SetBit(1, value); - } - - /// - /// Gets or sets a value indicating if the NVS line of products are supported - /// - public bool IsNVSSupported - { - get => _Flags.GetBit(2); - set => _Flags = _Flags.SetBit(2, value); - } - - /// - public override string ToString() - { - var supportedGPUs = new List(); - - if (IsGeForceSupported) - { - supportedGPUs.Add("GeForce"); - } - - if (IsQuadroSupported) - { - supportedGPUs.Add("Quadro"); - } - - if (IsNVSSupported) - { - supportedGPUs.Add("NVS"); - } - - if (supportedGPUs.Any()) - { - return $"[{_Flags}] = {string.Join(", ", supportedGPUs)}"; - } - - return $"[{_Flags}]"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileHandle.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileHandle.cs deleted file mode 100644 index 011b9f0f..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileHandle.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// DRSProfileHandle is a reference to a DRS profile. - /// - [StructLayout(LayoutKind.Sequential)] - public struct DRSProfileHandle : IHandle, IEquatable - { - internal readonly IntPtr _MemoryAddress; - - private DRSProfileHandle(IntPtr memoryAddress) - { - _MemoryAddress = memoryAddress; - } - - /// - public bool Equals(DRSProfileHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DRSProfileHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - - /// - public override string ToString() - { - return $"DRSProfileHandle #{MemoryAddress.ToInt64()}"; - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DRSProfileHandle left, DRSProfileHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DRSProfileHandle left, DRSProfileHandle right) - { - return !left.Equals(right); - } - - /// - /// Gets default DRSProfileHandle with a null pointer - /// - public static DRSProfileHandle DefaultHandle - { - get => default(DRSProfileHandle); - } - - /// - /// Gets the default global profile handle - /// - public static DRSProfileHandle DefaultGlobalProfileHandle - { - get => new DRSProfileHandle(new IntPtr(-1)); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileV1.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileV1.cs deleted file mode 100644 index 9b85af23..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSProfileV1.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// Represents a NVIDIA driver settings profile - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DRSProfileV1 : IInitializable - { - internal StructureVersion _Version; - internal UnicodeString _ProfileName; - internal DRSGPUSupport _GPUSupport; - internal uint _IsPredefined; - internal uint _NumberOfApplications; - internal uint _NumberOfSettings; - - /// - /// Creates a new instance of with the passed name and GPU series support list. - /// - /// The name of the profile. - /// An instance of containing the list of supported GPU series. - public DRSProfileV1(string name, DRSGPUSupport gpuSupport) - { - this = typeof(DRSProfileV1).Instantiate(); - _ProfileName = new UnicodeString(name); - _GPUSupport = gpuSupport; - } - - /// - /// Gets the name of the profile - /// - public string Name - { - get => _ProfileName.Value; - } - - /// - /// Gets or sets the GPU series support list - /// - public DRSGPUSupport GPUSupport - { - get => _GPUSupport; - set => _GPUSupport = value; - } - - /// - /// Gets a boolean value indicating if this profile is predefined - /// - public bool IsPredefined - { - get => _IsPredefined > 0; - } - - /// - /// Gets the number of applications registered under this profile - /// - public int NumberOfApplications - { - get => (int) _NumberOfApplications; - } - - /// - /// Gets the number of setting registered under this profile - /// - public int NumberOfSettings - { - get => (int) _NumberOfSettings; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSSessionHandle.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSSessionHandle.cs deleted file mode 100644 index 8b4e570d..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSSessionHandle.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// DRSSessionHandle is a reference to a DRS session. - /// - [StructLayout(LayoutKind.Sequential)] - public struct DRSSessionHandle : IHandle, IEquatable - { - internal readonly IntPtr _MemoryAddress; - - /// - public bool Equals(DRSSessionHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DRSSessionHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - - /// - public override string ToString() - { - return $"DRSSessionHandle #{MemoryAddress.ToInt64()}"; - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DRSSessionHandle left, DRSSessionHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DRSSessionHandle left, DRSSessionHandle right) - { - return !left.Equals(right); - } - - /// - /// Gets default DRSSessionHandle with a null pointer - /// - public static DRSSessionHandle DefaultHandle - { - get => default(DRSSessionHandle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingV1.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingV1.cs deleted file mode 100644 index 1c6e9161..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingV1.cs +++ /dev/null @@ -1,329 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// Represents a NVIDIA driver setting - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DRSSettingV1 : IInitializable - { - internal StructureVersion _Version; - internal UnicodeString _SettingName; - internal uint _SettingId; - internal DRSSettingType _SettingType; - internal DRSSettingLocation _SettingLocation; - internal uint _IsCurrentPredefined; - internal uint _IsPredefinedValid; - internal DRSSettingValue _PredefinedValue; - internal DRSSettingValue _CurrentValue; - - /// - /// Creates a new instance of containing the passed value. - /// - /// The setting identification number. - /// The type of the setting's value - /// The setting's value - public DRSSettingV1(uint id, DRSSettingType settingType, object value) - { - this = typeof(DRSSettingV1).Instantiate(); - Id = id; - IsPredefinedValueValid = false; - _SettingType = settingType; - CurrentValue = value; - } - - /// - /// Creates a new instance of containing the passed value. - /// - /// The setting identification number. - /// The setting's value - public DRSSettingV1(uint id, string value) : this(id, DRSSettingType.String, value) - { - } - - /// - /// Creates a new instance of containing the passed value. - /// - /// The setting identification number. - /// The setting's value - public DRSSettingV1(uint id, uint value) : this(id, DRSSettingType.Integer, value) - { - } - - /// - /// Creates a new instance of containing the passed value. - /// - /// The setting identification number. - /// The setting's value - public DRSSettingV1(uint id, byte[] value) : this(id, DRSSettingType.Binary, value) - { - } - - /// - /// Gets the name of the setting - /// - public string Name - { - get => _SettingName.Value; - } - - /// - /// Gets the identification number of the setting - /// - public uint Id - { - get => _SettingId; - private set => _SettingId = value; - } - - /// - /// Gets the setting's value type - /// - public DRSSettingType SettingType - { - get => _SettingType; - private set => _SettingType = value; - } - - /// - /// Gets the setting location - /// - public DRSSettingLocation SettingLocation - { - get => _SettingLocation; - } - - /// - /// Gets a boolean value indicating if the current value is the predefined value - /// - public bool IsCurrentValuePredefined - { - get => _IsCurrentPredefined > 0; - private set => _IsCurrentPredefined = value ? 1u : 0u; - } - - /// - /// Gets a boolean value indicating if the predefined value is available and valid - /// - public bool IsPredefinedValueValid - { - get => _IsPredefinedValid > 0; - private set => _IsPredefinedValid = value ? 1u : 0u; - } - - /// - /// Returns the predefined value as an integer - /// - /// An integer representing the predefined value - public uint GetPredefinedValueAsInteger() - { - return _PredefinedValue.AsInteger(); - } - - /// - /// Returns the predefined value as an array of bytes - /// - /// An byte array representing the predefined value - public byte[] GetPredefinedValueAsBinary() - { - return _PredefinedValue.AsBinary(); - } - - /// - /// Returns the predefined value as an unicode string - /// - /// An unicode string representing the predefined value - public string GetPredefinedValueAsUnicodeString() - { - return _PredefinedValue.AsUnicodeString(); - } - - /// - /// Gets the setting's predefined value - /// - public object PredefinedValue - { - get - { - if (!IsPredefinedValueValid) - { - return null; - } - - switch (_SettingType) - { - case DRSSettingType.Integer: - - return GetPredefinedValueAsInteger(); - case DRSSettingType.Binary: - - return GetPredefinedValueAsBinary(); - case DRSSettingType.String: - case DRSSettingType.UnicodeString: - - return GetPredefinedValueAsUnicodeString(); - default: - - throw new ArgumentOutOfRangeException(nameof(SettingType)); - } - } - } - - /// - /// Returns the current value as an integer - /// - /// An integer representing the current value - public uint GetCurrentValueAsInteger() - { - return _CurrentValue.AsInteger(); - } - - /// - /// Returns the current value as an array of bytes - /// - /// An byte array representing the current value - public byte[] GetCurrentValueAsBinary() - { - return _CurrentValue.AsBinary(); - } - - /// - /// Returns the current value as an unicode string - /// - /// An unicode string representing the current value - public string GetCurrentValueAsUnicodeString() - { - return _CurrentValue.AsUnicodeString(); - } - - /// - /// Sets the passed value as the current value - /// - /// The new value for the setting - public void SetCurrentValueAsInteger(uint value) - { - if (SettingType != DRSSettingType.Integer) - { - throw new ArgumentOutOfRangeException(nameof(value), "Passed argument is invalid for this setting."); - } - - _CurrentValue = new DRSSettingValue(value); - IsCurrentValuePredefined = IsPredefinedValueValid && (uint) CurrentValue == (uint) PredefinedValue; - } - - /// - /// Sets the passed value as the current value - /// - /// The new value for the setting - public void SetCurrentValueAsBinary(byte[] value) - { - if (SettingType != DRSSettingType.Binary) - { - throw new ArgumentOutOfRangeException(nameof(value), "Passed argument is invalid for this setting."); - } - - _CurrentValue = new DRSSettingValue(value); - IsCurrentValuePredefined = - IsPredefinedValueValid && - ((byte[]) CurrentValue)?.SequenceEqual((byte[]) PredefinedValue ?? new byte[0]) == true; - } - - /// - /// Sets the passed value as the current value - /// - /// The new value for the setting - public void SetCurrentValueAsUnicodeString(string value) - { - if (SettingType != DRSSettingType.UnicodeString) - { - throw new ArgumentOutOfRangeException(nameof(value), "Passed argument is invalid for this setting."); - } - - _CurrentValue = new DRSSettingValue(value); - IsCurrentValuePredefined = - IsPredefinedValueValid && - string.Equals( - (string) CurrentValue, - (string) PredefinedValue, - StringComparison.InvariantCulture - ); - } - - /// - /// Gets or sets the setting's current value - /// - public object CurrentValue - { - get - { - switch (_SettingType) - { - case DRSSettingType.Integer: - - return GetCurrentValueAsInteger(); - case DRSSettingType.Binary: - - return GetCurrentValueAsBinary(); - case DRSSettingType.String: - case DRSSettingType.UnicodeString: - - return GetCurrentValueAsUnicodeString(); - default: - - throw new ArgumentOutOfRangeException(nameof(SettingType)); - } - } - private set - { - if (value is int intValue) - { - SetCurrentValueAsInteger((uint) intValue); - } - else if (value is uint unsignedIntValue) - { - SetCurrentValueAsInteger(unsignedIntValue); - } - else if (value is short shortValue) - { - SetCurrentValueAsInteger((uint) shortValue); - } - else if (value is ushort unsignedShortValue) - { - SetCurrentValueAsInteger(unsignedShortValue); - } - else if (value is long longValue) - { - SetCurrentValueAsInteger((uint) longValue); - } - else if (value is ulong unsignedLongValue) - { - SetCurrentValueAsInteger((uint) unsignedLongValue); - } - else if (value is byte byteValue) - { - SetCurrentValueAsInteger(byteValue); - } - else if (value is string stringValue) - { - SetCurrentValueAsUnicodeString(stringValue); - } - else if (value is byte[] binaryValue) - { - SetCurrentValueAsBinary(binaryValue); - } - else - { - throw new ArgumentException("Unacceptable argument type.", nameof(value)); - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValue.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValue.cs deleted file mode 100644 index c57a59af..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValue.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// Represents a setting value - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct DRSSettingValue : IInitializable - { - private const int UnicodeStringLength = UnicodeString.UnicodeStringLength; - private const int BinaryDataMax = 4096; - - // Math.Max(BinaryDataMax + sizeof(uint), UnicodeStringLength * sizeof(ushort)) - private const int FullStructureSize = 4100; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = FullStructureSize, ArraySubType = UnmanagedType.U1)] - internal byte[] _BinaryValue; - - /// - /// Creates a new instance of containing the passed unicode string as the value - /// - /// The unicode string value - public DRSSettingValue(string value) - { - if (value?.Length > UnicodeStringLength) - { - value = value.Substring(0, UnicodeStringLength); - } - - _BinaryValue = new byte[FullStructureSize]; - - var stringBytes = Encoding.Unicode.GetBytes(value ?? string.Empty); - Array.Copy(stringBytes, 0, _BinaryValue, 0, Math.Min(stringBytes.Length, _BinaryValue.Length)); - } - - /// - /// Creates a new instance of containing the passed byte array as the value - /// - /// The byte array value - public DRSSettingValue(byte[] value) - { - _BinaryValue = new byte[FullStructureSize]; - - if (value?.Length > 0) - { - var arrayLength = Math.Min(value.Length, BinaryDataMax); - var arrayLengthBytes = BitConverter.GetBytes((uint) arrayLength); - Array.Copy(arrayLengthBytes, 0, _BinaryValue, 0, arrayLengthBytes.Length); - Array.Copy(value, 0, _BinaryValue, arrayLengthBytes.Length, arrayLength); - } - } - - /// - /// Creates a new instance of containing the passed integer as the value - /// - /// The integer value - public DRSSettingValue(uint value) - { - _BinaryValue = new byte[FullStructureSize]; - var arrayLengthBytes = BitConverter.GetBytes(value); - Array.Copy(arrayLengthBytes, 0, _BinaryValue, 0, arrayLengthBytes.Length); - } - - /// - /// Returns the value as an integer - /// - /// An integer representing the value - public uint AsInteger() - { - return BitConverter.ToUInt32(_BinaryValue, 0); - } - - /// - /// Returns the value as an array of bytes - /// - /// An array of bytes representing the value - public byte[] AsBinary() - { - return _BinaryValue.Skip(sizeof(uint)).Take((int) AsInteger()).ToArray(); - } - - /// - /// Returns the value as an unicode string - /// - /// An unicode string representing the value - public string AsUnicodeString() - { - return Encoding.Unicode.GetString(_BinaryValue).TrimEnd('\0'); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValues.cs b/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValues.cs deleted file mode 100644 index 61dd84a2..00000000 --- a/app/NvAPIWrapper/Native/DRS/Structures/DRSSettingValues.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.DRS.Structures -{ - /// - /// Contains a list of all possible values for a setting as well as its default value - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DRSSettingValues : IInitializable - { - internal const int MaximumNumberOfValues = 100; - internal StructureVersion _Version; - internal uint _NumberOfValues; - internal DRSSettingType _SettingType; - internal DRSSettingValue _DefaultValue; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfValues)] - internal DRSSettingValue[] _Values; - - /// - /// Gets the setting's value type - /// - public DRSSettingType SettingType - { - get => _SettingType; - } - - /// - /// Gets a list of possible values for the setting - /// - public object[] Values - { - get - { - switch (_SettingType) - { - case DRSSettingType.Integer: - - return ValuesAsInteger().Cast().ToArray(); - case DRSSettingType.Binary: - - return ValuesAsBinary().Cast().ToArray(); - case DRSSettingType.String: - case DRSSettingType.UnicodeString: - - return ValuesAsUnicodeString().Cast().ToArray(); - default: - - throw new ArgumentOutOfRangeException(nameof(SettingType)); - } - } - } - - /// - /// Gets the default value of the setting - /// - public object DefaultValue - { - get - { - switch (_SettingType) - { - case DRSSettingType.Integer: - - return DefaultValueAsInteger(); - case DRSSettingType.Binary: - - return DefaultValueAsBinary(); - case DRSSettingType.String: - case DRSSettingType.UnicodeString: - - return DefaultValueAsUnicodeString(); - default: - - throw new ArgumentOutOfRangeException(nameof(SettingType)); - } - } - } - - /// - /// Returns the default value as an integer - /// - /// An integer representing the default value - public uint DefaultValueAsInteger() - { - return _DefaultValue.AsInteger(); - } - - /// - /// Returns the default value as a byte array - /// - /// An array of bytes representing the default value - public byte[] DefaultValueAsBinary() - { - return _DefaultValue.AsBinary(); - } - - /// - /// Returns the default value as an unicode string - /// - /// A string representing the default value - public string DefaultValueAsUnicodeString() - { - return _DefaultValue.AsUnicodeString(); - } - - /// - /// Returns the setting's possible values as an array of integers - /// - /// An array of integers representing the possible values - public uint[] ValuesAsInteger() - { - return _Values.Take((int) _NumberOfValues).Select(value => value.AsInteger()).ToArray(); - } - - /// - /// Returns the setting's possible values as an array of byte arrays - /// - /// An array of byte arrays representing the possible values - public byte[][] ValuesAsBinary() - { - return _Values.Take((int) _NumberOfValues).Select(value => value.AsBinary()).ToArray(); - } - - /// - /// Returns the setting's possible values as an array of unicode strings - /// - /// An array of unicode strings representing the possible values - public string[] ValuesAsUnicodeString() - { - return _Values.Take((int) _NumberOfValues).Select(value => value.AsUnicodeString()).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DRSApi.cs b/app/NvAPIWrapper/Native/DRSApi.cs deleted file mode 100644 index 647a4725..00000000 --- a/app/NvAPIWrapper/Native/DRSApi.cs +++ /dev/null @@ -1,936 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using NvAPIWrapper.Native.DRS.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.DRS; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains driver settings static functions - /// - // ReSharper disable once ClassTooBig - public static class DRSApi - { - /// - /// This API adds an executable name to a profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input instance containing the executable name. - /// The newly created instance of . - public static IDRSApplication CreateApplication( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - IDRSApplication application) - { - using (var applicationReference = ValueTypeReference.FromValueType(application, application.GetType())) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - applicationReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return applicationReference.ToValueType(application.GetType()); - } - } - - /// - /// This API creates an empty profile. - /// - /// Input to the session handle. - /// Input to the instance. - /// The newly created profile handle. - public static DRSProfileHandle CreateProfile(DRSSessionHandle sessionHandle, DRSProfileV1 profile) - { - using (var profileReference = ValueTypeReference.FromValueType(profile)) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileReference, - out var profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return profileHandle; - } - } - - /// - /// This API allocates memory and initializes the session. - /// - /// The newly created session handle. - public static DRSSessionHandle CreateSession() - { - var status = DelegateFactory.GetDelegate()(out var sessionHandle); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return sessionHandle; - } - - /// - /// This API removes an executable from a profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input all the information about the application to be removed. - public static void DeleteApplication( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - IDRSApplication application) - { - using (var applicationReference = ValueTypeReference.FromValueType(application, application.GetType())) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - applicationReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This API removes an executable name from a profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input the executable name to be removed. - public static void DeleteApplication( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - string applicationName) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - new UnicodeString(applicationName) - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API deletes a profile or sets it back to a predefined value. - /// - /// Input to the session handle. - /// Input profile handle. - public static void DeleteProfile(DRSSessionHandle sessionHandle, DRSProfileHandle profileHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API deletes a setting or sets it back to predefined value. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input settingId to be deleted. - public static void DeleteProfileSetting( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - uint settingId) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - settingId - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API frees the allocated resources for the session handle. - /// - /// Input to the session handle. - public static void DestroySession(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()(sessionHandle); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API enumerates all the applications in a given profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// Instances of with all the attributes filled. - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IEnumerable EnumApplications( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle) - { - var maxApplicationsPerRequest = 8; - var enumApplications = DelegateFactory.GetDelegate(); - - foreach (var acceptType in enumApplications.Accepts()) - { - var i = 0u; - - while (true) - { - var instances = acceptType.Instantiate().Repeat(maxApplicationsPerRequest); - - using (var applicationsReference = ValueTypeArray.FromArray(instances, acceptType)) - { - var count = (uint) instances.Length; - var status = enumApplications( - sessionHandle, - profileHandle, - i, - ref count, - applicationsReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - break; - } - - if (status == Status.EndEnumeration) - { - yield break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - foreach (var application in applicationsReference.ToArray( - (int) count, - acceptType)) - { - yield return application; - i++; - } - - if (count < maxApplicationsPerRequest) - { - yield break; - } - } - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API enumerates all the Ids of all the settings recognized by NVAPI. - /// - /// An array of s filled with the settings identification numbers of available settings. - public static uint[] EnumAvailableSettingIds() - { - var settingIdsCount = (uint) ushort.MaxValue; - var settingIds = 0u.Repeat((int) settingIdsCount); - - using (var settingIdsArray = ValueTypeArray.FromArray(settingIds)) - { - var status = DelegateFactory.GetDelegate()( - settingIdsArray, - ref settingIdsCount - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return settingIdsArray.ToArray((int) settingIdsCount); - } - } - - /// - /// This API enumerates all available setting values for a given setting. - /// - /// Input settingId. - /// All available setting values. - public static DRSSettingValues EnumAvailableSettingValues(uint settingId) - { - var settingValuesCount = (uint) DRSSettingValues.MaximumNumberOfValues; - var settingValues = typeof(DRSSettingValues).Instantiate(); - - using (var settingValuesReference = ValueTypeReference.FromValueType(settingValues)) - { - var status = DelegateFactory.GetDelegate()( - settingId, - ref settingValuesCount, - settingValuesReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return settingValuesReference.ToValueType(typeof(DRSSettingValues)); - } - } - - /// - /// This API enumerates through all the profiles in the session. - /// - /// Input to the session handle. - /// Instances of each representing a profile. - public static IEnumerable EnumProfiles(DRSSessionHandle sessionHandle) - { - var i = 0u; - - while (true) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - i, - out var profileHandle - ); - - if (status == Status.EndEnumeration) - { - yield break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - yield return profileHandle; - i++; - } - } - - /// - /// This API enumerates all the settings of a given profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// Instances of . - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IEnumerable EnumSettings( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle) - { - var maxSettingsPerRequest = 32; - var enumSettings = DelegateFactory.GetDelegate(); - - var i = 0u; - - while (true) - { - var instances = typeof(DRSSettingV1).Instantiate().Repeat(maxSettingsPerRequest); - - using (var applicationsReference = ValueTypeArray.FromArray(instances)) - { - var count = (uint) instances.Length; - var status = enumSettings( - sessionHandle, - profileHandle, - i, - ref count, - applicationsReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status == Status.EndEnumeration) - { - yield break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - foreach (var application in applicationsReference.ToArray( - (int) count, - typeof(DRSSettingV1)) - ) - { - yield return application; - i++; - } - - if (count < maxSettingsPerRequest) - { - yield break; - } - } - } - } - - /// - /// This API searches the application and the associated profile for the given application name. - /// If a fully qualified path is provided, this function will always return the profile - /// the driver will apply upon running the application (on the path provided). - /// - /// Input to the hSession handle - /// Input appName. For best results, provide a fully qualified path of the type - /// The profile handle of the profile that the found application belongs to. - /// An instance of . - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IDRSApplication FindApplicationByName( - DRSSessionHandle sessionHandle, - string applicationName, - out DRSProfileHandle? profileHandle) - { - var findApplicationByName = DelegateFactory.GetDelegate(); - - foreach (var acceptType in findApplicationByName.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var applicationReference = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = findApplicationByName( - sessionHandle, - new UnicodeString(applicationName), - out var applicationProfileHandle, - applicationReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status == Status.ExecutableNotFound) - { - profileHandle = null; - - return null; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - profileHandle = applicationProfileHandle; - - return applicationReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API finds a profile in the current session. - /// - /// Input to the session handle. - /// Input profileName. - /// The profile handle. - public static DRSProfileHandle FindProfileByName(DRSSessionHandle sessionHandle, string profileName) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - new UnicodeString(profileName), - out var profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return profileHandle; - } - - /// - /// This API gets information about the given application. The input application name - /// must match exactly what the Profile has stored for the application. - /// This function is better used to retrieve application information from a previous - /// enumeration. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input application name. - /// - /// An instance of with all attributes filled if found; otherwise - /// . - /// - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IDRSApplication GetApplicationInfo( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - string applicationName) - { - var getApplicationInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getApplicationInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var applicationReference = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getApplicationInfo( - sessionHandle, - profileHandle, - new UnicodeString(applicationName), - applicationReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status == Status.ExecutableNotFound) - { - return null; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return applicationReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// Returns the handle to the current global profile. - /// - /// Input to the session handle. - /// Base profile handle. - public static DRSProfileHandle GetBaseProfile(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - out var profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return profileHandle; - } - - /// - /// This API returns the handle to the current global profile. - /// - /// Input to the session handle. - /// Current global profile handle. - public static DRSProfileHandle GetCurrentGlobalProfile(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - out var profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return profileHandle; - } - - /// - /// This API obtains the number of profiles in the current session object. - /// - /// Input to the session handle. - /// Number of profiles in the current session. - public static int GetNumberOfProfiles(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - out var profileCount - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) profileCount; - } - - /// - /// This API gets information about the given profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// An instance of with all attributes filled. - public static DRSProfileV1 GetProfileInfo(DRSSessionHandle sessionHandle, DRSProfileHandle profileHandle) - { - var profile = typeof(DRSProfileV1).Instantiate(); - - using (var profileReference = ValueTypeReference.FromValueType(profile)) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - profileReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return profileReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API gets information about the given setting. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input settingId. - /// An instance of describing the setting if found; otherwise . - public static DRSSettingV1? GetSetting( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - uint settingId) - { - var instance = typeof(DRSSettingV1).Instantiate(); - - using (var settingReference = ValueTypeReference.FromValueType(instance, typeof(DRSSettingV1))) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - settingId, - settingReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status == Status.SettingNotFound) - { - return null; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return settingReference.ToValueType(typeof(DRSSettingV1)); - } - } - - /// - /// This API gets the binary identification number of a setting given the setting name. - /// - /// Input Unicode settingName. - /// The corresponding settingId. - public static uint GetSettingIdFromName(string settingName) - { - var status = DelegateFactory.GetDelegate()( - new UnicodeString(settingName), - out var settingId - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return settingId; - } - - /// - /// This API gets the setting name given the binary identification number. - /// - /// Input settingId. - /// Corresponding settingName. - public static string GetSettingNameFromId(uint settingId) - { - var status = DelegateFactory.GetDelegate()( - settingId, - out var settingName - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return settingName.Value; - } - - /// - /// This API loads and parses the settings data. - /// - /// Input to the session handle. - public static void LoadSettings(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()(sessionHandle); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API loads settings from the given file path. - /// - /// Input to the session handle - /// Binary full file path. - public static void LoadSettings(DRSSessionHandle sessionHandle, string fileName) - { - var unicodeFileName = new UnicodeString(fileName); - var status = DelegateFactory.GetDelegate()( - sessionHandle, - unicodeFileName - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API restores the whole system to predefined(default) values. - /// - /// Input to the session handle. - public static void RestoreDefaults(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API restores the given profile to predefined(default) values. - /// Any and all user specified modifications will be removed. - /// If the whole profile was set by the user, the profile will be removed. - /// - /// Input to the session handle. - /// Input profile handle. - public static void RestoreDefaults( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API restores the given profile setting to predefined(default) values. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input settingId. - public static void RestoreDefaults( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - uint settingId) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - settingId - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API saves the settings data to the system. - /// - /// Input to the session handle. - public static void SaveSettings(DRSSessionHandle sessionHandle) - { - var status = DelegateFactory.GetDelegate()(sessionHandle); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API saves settings to the given file path. - /// - /// Input to the session handle. - /// Binary full file path. - public static void SaveSettings(DRSSessionHandle sessionHandle, string fileName) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - new UnicodeString(fileName) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the current global profile in the driver. - /// - /// Input to the session handle. - /// Input the new current global profile name. - public static void SetCurrentGlobalProfile(DRSSessionHandle sessionHandle, string profileName) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - new UnicodeString(profileName) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// Specifies flags for a given profile. Currently only the GPUSupport is - /// used to update the profile. Neither the name, number of settings or applications - /// or other profile information can be changed with this function. - /// - /// Input to the session handle. - /// Input profile handle. - /// Input the new profile info. - public static void SetProfileInfo( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - DRSProfileV1 profile) - { - using (var profileReference = ValueTypeReference.FromValueType(profile)) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - profileReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This API adds/modifies a setting to a profile. - /// - /// Input to the session handle. - /// Input profile handle. - /// - /// An instance of containing the setting identification number and new - /// value for the setting. - /// - public static void SetSetting( - DRSSessionHandle sessionHandle, - DRSProfileHandle profileHandle, - DRSSettingV1 setting) - { - using (var settingReference = ValueTypeReference.FromValueType(setting, setting.GetType())) - { - var status = DelegateFactory.GetDelegate()( - sessionHandle, - profileHandle, - settingReference - ); - - if (status == Status.IncompatibleStructureVersion) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/DRS.cs b/app/NvAPIWrapper/Native/Delegates/DRS.cs deleted file mode 100644 index 9ab271d5..00000000 --- a/app/NvAPIWrapper/Native/Delegates/DRS.cs +++ /dev/null @@ -1,255 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.DRS.Structures; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -namespace NvAPIWrapper.Native.Delegates -{ - // ReSharper disable InconsistentNaming - internal static class DRS - { - [FunctionId(FunctionId.NvAPI_DRS_CreateApplication)] - public delegate Status NvAPI_DRS_CreateApplication( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] - [Accepts( - typeof(DRSApplicationV4), - typeof(DRSApplicationV3), - typeof(DRSApplicationV2), - typeof(DRSApplicationV1) - )] - ValueTypeReference application - ); - - [FunctionId(FunctionId.NvAPI_DRS_CreateProfile)] - public delegate Status NvAPI_DRS_CreateProfile( - [In] DRSSessionHandle sessionHandle, - [In] [Accepts(typeof(DRSProfileV1))] ValueTypeReference profile, - [Out] out DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_CreateSession)] - public delegate Status NvAPI_DRS_CreateSession([Out] out DRSSessionHandle sessionHandle); - - [FunctionId(FunctionId.NvAPI_DRS_DeleteApplication)] - public delegate Status NvAPI_DRS_DeleteApplication( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] UnicodeString applicationName - ); - - [FunctionId(FunctionId.NvAPI_DRS_DeleteApplicationEx)] - public delegate Status NvAPI_DRS_DeleteApplicationEx( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] - [Accepts(typeof(DRSApplicationV1), typeof(DRSApplicationV2), typeof(DRSApplicationV3), - typeof(DRSApplicationV4))] - ValueTypeReference application - ); - - [FunctionId(FunctionId.NvAPI_DRS_DeleteProfile)] - public delegate Status NvAPI_DRS_DeleteProfile( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_DeleteProfileSetting)] - public delegate Status NvAPI_DRS_DeleteProfileSetting( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] uint settingId - ); - - [FunctionId(FunctionId.NvAPI_DRS_DestroySession)] - public delegate Status NvAPI_DRS_DestroySession([In] DRSSessionHandle sessionHandle); - - [FunctionId(FunctionId.NvAPI_DRS_EnumApplications)] - public delegate Status NvAPI_DRS_EnumApplications( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] uint index, - [In] [Out] ref uint count, - [In] - [Accepts( - typeof(DRSApplicationV4), - typeof(DRSApplicationV3), - typeof(DRSApplicationV2), - typeof(DRSApplicationV1) - )] - ValueTypeArray applications - ); - - [FunctionId(FunctionId.NvAPI_DRS_EnumAvailableSettingIds)] - public delegate Status NvAPI_DRS_EnumAvailableSettingIds( - [In] [Accepts(typeof(uint))] ValueTypeArray settingIds, - [In] [Out] ref uint count - ); - - [FunctionId(FunctionId.NvAPI_DRS_EnumAvailableSettingValues)] - public delegate Status NvAPI_DRS_EnumAvailableSettingValues( - [In] uint settingId, - [In] [Out] ref uint count, - [In] [Out] [Accepts(typeof(DRSSettingValues))] - ValueTypeReference settingValues - ); - - [FunctionId(FunctionId.NvAPI_DRS_EnumProfiles)] - public delegate Status NvAPI_DRS_EnumProfiles( - [In] DRSSessionHandle sessionHandle, - [In] uint index, - [Out] out DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_EnumSettings)] - public delegate Status NvAPI_DRS_EnumSettings( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] uint index, - [In] [Out] ref uint count, - [In] [Out] [Accepts(typeof(DRSSettingV1))] - ValueTypeArray settings - ); - - [FunctionId(FunctionId.NvAPI_DRS_FindApplicationByName)] - public delegate Status NvAPI_DRS_FindApplicationByName( - [In] DRSSessionHandle sessionHandle, - [In] UnicodeString applicationName, - [Out] out DRSProfileHandle profileHandle, - [In] - [Accepts( - typeof(DRSApplicationV4), - typeof(DRSApplicationV3), - typeof(DRSApplicationV2), - typeof(DRSApplicationV1) - )] - ValueTypeReference application - ); - - [FunctionId(FunctionId.NvAPI_DRS_FindProfileByName)] - public delegate Status NvAPI_DRS_FindProfileByName( - [In] DRSSessionHandle sessionHandle, - [In] UnicodeString profileName, - [Out] out DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetApplicationInfo)] - public delegate Status NvAPI_DRS_GetApplicationInfo( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] UnicodeString applicationName, - [In] - [Accepts( - typeof(DRSApplicationV4), - typeof(DRSApplicationV3), - typeof(DRSApplicationV2), - typeof(DRSApplicationV1) - )] - ValueTypeReference application - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetBaseProfile)] - public delegate Status NvAPI_DRS_GetBaseProfile( - [In] DRSSessionHandle sessionHandle, - [Out] out DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetCurrentGlobalProfile)] - public delegate Status NvAPI_DRS_GetCurrentGlobalProfile( - [In] DRSSessionHandle sessionHandle, - [Out] out DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetNumProfiles)] - public delegate Status NvAPI_DRS_GetNumProfiles([In] DRSSessionHandle sessionHandle, [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_DRS_GetProfileInfo)] - public delegate Status NvAPI_DRS_GetProfileInfo( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] [Accepts(typeof(DRSProfileV1))] ValueTypeReference profile - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetSetting)] - public delegate Status NvAPI_DRS_GetSetting( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] uint settingId, - [Out] [Accepts(typeof(DRSSettingV1))] ValueTypeReference setting - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetSettingIdFromName)] - public delegate Status NvAPI_DRS_GetSettingIdFromName( - [In] UnicodeString settingName, - [Out] out uint settingId - ); - - [FunctionId(FunctionId.NvAPI_DRS_GetSettingNameFromId)] - public delegate Status NvAPI_DRS_GetSettingNameFromId( - [In] uint settingId, - [Out] out UnicodeString settingName - ); - - [FunctionId(FunctionId.NvAPI_DRS_LoadSettings)] - public delegate Status NvAPI_DRS_LoadSettings([In] DRSSessionHandle sessionHandle); - - [FunctionId(FunctionId.NvAPI_DRS_LoadSettingsFromFile)] - public delegate Status NvAPI_DRS_LoadSettingsFromFile( - [In] DRSSessionHandle sessionHandle, - [In] UnicodeString fileName - ); - - - [FunctionId(FunctionId.NvAPI_DRS_RestoreAllDefaults)] - public delegate Status NvAPI_DRS_RestoreAllDefaults( - [In] DRSSessionHandle sessionHandle - ); - - - [FunctionId(FunctionId.NvAPI_DRS_RestoreProfileDefault)] - public delegate Status NvAPI_DRS_RestoreProfileDefault( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle - ); - - [FunctionId(FunctionId.NvAPI_DRS_RestoreProfileDefaultSetting)] - public delegate Status NvAPI_DRS_RestoreProfileDefaultSetting( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] uint settingId - ); - - [FunctionId(FunctionId.NvAPI_DRS_SaveSettings)] - public delegate Status NvAPI_DRS_SaveSettings([In] DRSSessionHandle sessionHandle); - - [FunctionId(FunctionId.NvAPI_DRS_SaveSettingsToFile)] - public delegate Status NvAPI_DRS_SaveSettingsToFile( - [In] DRSSessionHandle sessionHandle, - [In] UnicodeString fileName - ); - - [FunctionId(FunctionId.NvAPI_DRS_SetCurrentGlobalProfile)] - public delegate Status NvAPI_DRS_SetCurrentGlobalProfile( - [In] DRSSessionHandle sessionHandle, - [In] UnicodeString profileName - ); - - [FunctionId(FunctionId.NvAPI_DRS_SetProfileInfo)] - public delegate Status NvAPI_DRS_SetProfileInfo( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] [Accepts(typeof(DRSProfileV1))] ValueTypeReference profile - ); - - [FunctionId(FunctionId.NvAPI_DRS_SetSetting)] - public delegate Status NvAPI_DRS_SetSetting( - [In] DRSSessionHandle sessionHandle, - [In] DRSProfileHandle profileHandle, - [In] [Accepts(typeof(DRSSettingV1))] ValueTypeReference setting - ); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/Display.cs b/app/NvAPIWrapper/Native/Delegates/Display.cs deleted file mode 100644 index 4abc9fa2..00000000 --- a/app/NvAPIWrapper/Native/Delegates/Display.cs +++ /dev/null @@ -1,328 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; - -// ReSharper disable InconsistentNaming - -namespace NvAPIWrapper.Native.Delegates -{ - internal static class Display - { - [FunctionId(FunctionId.NvAPI_CreateDisplayFromUnAttachedDisplay)] - public delegate Status NvAPI_CreateDisplayFromUnAttachedDisplay( - [In] UnAttachedDisplayHandle display, - [Out] out DisplayHandle newDisplay - ); - - [FunctionId(FunctionId.NvAPI_Disp_ColorControl)] - public delegate Status NvAPI_Disp_ColorControl( - [In] uint displayId, - [In] - [Out] - [Accepts( - typeof(ColorDataV5), - typeof(ColorDataV4), - typeof(ColorDataV3), - typeof(ColorDataV2), - typeof(ColorDataV1) - )] - ValueTypeReference colorData - ); - - [FunctionId(FunctionId.NvAPI_DISP_DeleteCustomDisplay)] - public delegate Status NvAPI_DISP_DeleteCustomDisplay( - [In] [Accepts(typeof(uint))] ValueTypeArray displayIds, - [In] uint count, - [In] [Accepts(typeof(CustomDisplay))] ValueTypeReference customDisplay - ); - - [FunctionId(FunctionId.NvAPI_DISP_EnumCustomDisplay)] - public delegate Status NvAPI_DISP_EnumCustomDisplay( - [In] uint displayId, - [In] uint index, - [In] [Accepts(typeof(CustomDisplay))] ValueTypeReference customDisplay - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle)] - public delegate Status NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle( - [In] [MarshalAs(UnmanagedType.LPStr)] string displayName, - [Out] out UnAttachedDisplayHandle display - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetDisplayConfig)] - public delegate Status NvAPI_DISP_GetDisplayConfig( - [In] [Out] ref uint pathInfoCount, - [In] [Accepts(typeof(PathInfoV2), typeof(PathInfoV1))] - ValueTypeArray pathInfos - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetDisplayIdByDisplayName)] - public delegate Status NvAPI_DISP_GetDisplayIdByDisplayName([In] string displayName, [Out] out uint displayId); - - [FunctionId(FunctionId.NvAPI_DISP_GetGDIPrimaryDisplayId)] - public delegate Status NvAPI_DISP_GetGDIPrimaryDisplayId([Out] out uint displayId); - - [FunctionId(FunctionId.NvAPI_Disp_GetHdrCapabilities)] - public delegate Status NvAPI_Disp_GetHdrCapabilities( - [In] uint displayId, - [In] [Out] [Accepts(typeof(HDRCapabilitiesV1))] - ValueTypeReference hdrCapabilities - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetMonitorCapabilities)] - public delegate Status NvAPI_DISP_GetMonitorCapabilities( - [In] uint displayId, - [In] [Accepts(typeof(MonitorCapabilities))] - ValueTypeReference capabilities - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetMonitorColorCapabilities)] - public delegate Status NvAPI_DISP_GetMonitorColorCapabilities( - [In] uint displayId, - [In] [Accepts(typeof(MonitorColorData))] - ValueTypeArray capabilities, - [In] [Out] ref uint count - ); - - [FunctionId(FunctionId.NvAPI_DISP_GetTiming)] - public delegate Status NvAPI_DISP_GetTiming( - [In] uint displayId, - [In] [Accepts(typeof(TimingInput))] ValueTypeReference timingInput, - [In] [Accepts(typeof(Timing))] ValueTypeReference timing - ); - - [FunctionId(FunctionId.NvAPI_Disp_HdrColorControl)] - public delegate Status NvAPI_Disp_HdrColorControl( - [In] uint displayId, - [In] [Out] [Accepts(typeof(HDRColorDataV2), typeof(HDRColorDataV1))] - ValueTypeReference hdrColorData - ); - - [FunctionId(FunctionId.NvAPI_Disp_InfoFrameControl)] - public delegate Status NvAPI_Disp_InfoFrameControl( - [In] uint displayId, - [In] [Accepts(typeof(InfoFrameData))] ValueTypeReference infoFrameData - ); - - [FunctionId(FunctionId.NvAPI_DISP_RevertCustomDisplayTrial)] - public delegate Status NvAPI_DISP_RevertCustomDisplayTrial( - [In] [Accepts(typeof(uint))] ValueTypeArray displayIds, - [In] uint count - ); - - [FunctionId(FunctionId.NvAPI_DISP_SaveCustomDisplay)] - public delegate Status NvAPI_DISP_SaveCustomDisplay( - [In] [Accepts(typeof(uint))] ValueTypeArray displayIds, - [In] uint count, - [In] uint isThisOutputIdOnly, - [In] uint isThisMonitorIdOnly - ); - - [FunctionId(FunctionId.NvAPI_DISP_SetDisplayConfig)] - public delegate Status NvAPI_DISP_SetDisplayConfig( - [In] uint pathInfoCount, - [In] [Accepts(typeof(PathInfoV2), typeof(PathInfoV1))] - ValueTypeArray pathInfos, - [In] DisplayConfigFlags flags - ); - - [FunctionId(FunctionId.NvAPI_DISP_TryCustomDisplay)] - public delegate Status NvAPI_DISP_TryCustomDisplay( - [In] [Accepts(typeof(uint))] ValueTypeArray displayIds, - [In] uint count, - [In] [Accepts(typeof(CustomDisplay))] ValueTypeArray customDisplays - ); - - [FunctionId(FunctionId.NvAPI_EnumNvidiaDisplayHandle)] - public delegate Status NvAPI_EnumNvidiaDisplayHandle( - [In] uint enumId, - [Out] out DisplayHandle display - ); - - [FunctionId(FunctionId.NvAPI_EnumNvidiaUnAttachedDisplayHandle)] - public delegate Status NvAPI_EnumNvidiaUnAttachedDisplayHandle( - [In] uint enumId, - [Out] out UnAttachedDisplayHandle display - ); - - [FunctionId(FunctionId.NvAPI_GetAssociatedDisplayOutputId)] - public delegate Status NvAPI_GetAssociatedDisplayOutputId( - [In] DisplayHandle display, - [Out] out OutputId outputId - ); - - [FunctionId(FunctionId.NvAPI_GetAssociatedNvidiaDisplayHandle)] - public delegate Status NvAPI_GetAssociatedNvidiaDisplayHandle( - [In] [MarshalAs(UnmanagedType.LPStr)] string displayName, - [Out] out DisplayHandle display - ); - - [FunctionId(FunctionId.NvAPI_GetAssociatedNvidiaDisplayName)] - public delegate Status NvAPI_GetAssociatedNvidiaDisplayName( - [In] DisplayHandle display, - [Out] out ShortString displayName - ); - - [FunctionId(FunctionId.NvAPI_GetDisplayDriverBuildTitle)] - public delegate Status NvAPI_GetDisplayDriverBuildTitle( - [In] DisplayHandle displayHandle, - [Out] out ShortString name - ); - - [FunctionId(FunctionId.NvAPI_GetDisplayDriverMemoryInfo)] - public delegate Status NvAPI_GetDisplayDriverMemoryInfo( - [In] DisplayHandle displayHandle, - [In] - [Accepts( - typeof(DisplayDriverMemoryInfoV3), - typeof(DisplayDriverMemoryInfoV2), - typeof(DisplayDriverMemoryInfoV1) - )] - ValueTypeReference memoryInfo - ); - - [FunctionId(FunctionId.NvAPI_GetDVCInfo)] - public delegate Status NvAPI_GetDVCInfo( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] [Accepts(typeof(PrivateDisplayDVCInfo))] - ValueTypeReference dvcInfo - ); - - [FunctionId(FunctionId.NvAPI_GetDVCInfoEx)] - public delegate Status NvAPI_GetDVCInfoEx( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] [Accepts(typeof(PrivateDisplayDVCInfoEx))] - ValueTypeReference dvcInfo - ); - - [FunctionId(FunctionId.NvAPI_GetHDMISupportInfo)] - public delegate Status NvAPI_GetHDMISupportInfo( - [In] DisplayHandle displayHandle, - [In] uint displayIdOrOutputId, - [In] [Accepts(typeof(HDMISupportInfoV2), typeof(HDMISupportInfoV1))] - ValueTypeReference supportInfo - ); - - [FunctionId(FunctionId.NvAPI_GetHUEInfo)] - public delegate Status NvAPI_GetHUEInfo( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] [Accepts(typeof(PrivateDisplayHUEInfo))] - ValueTypeReference hueInfo - ); - - [FunctionId(FunctionId.NvAPI_GetSupportedViews)] - public delegate Status NvAPI_GetSupportedViews( - [In] DisplayHandle display, - [In] [Accepts(typeof(TargetViewMode))] ValueTypeArray viewModes, - [Out] [In] ref uint viewCount - ); - - [FunctionId(FunctionId.NvAPI_GetUnAttachedAssociatedDisplayName)] - public delegate Status NvAPI_GetUnAttachedAssociatedDisplayName( - [In] UnAttachedDisplayHandle display, - [Out] out ShortString displayName - ); - - [FunctionId(FunctionId.NvAPI_GPU_GetScanoutCompositionParameter)] - public delegate Status NvAPI_GPU_GetScanOutCompositionParameter( - [In] uint displayId, - [In] ScanOutCompositionParameter parameter, - [Out] out ScanOutCompositionParameterValue parameterValue, - [Out] out float container - ); - - [FunctionId(FunctionId.NvAPI_GPU_GetScanoutConfiguration)] - public delegate Status NvAPI_GPU_GetScanOutConfiguration( - [In] uint displayId, - [In] [Accepts(typeof(Rectangle))] ValueTypeReference desktopRectangle, - [In] [Accepts(typeof(Rectangle))] ValueTypeReference scanOutRectangle - ); - - [FunctionId(FunctionId.NvAPI_GPU_GetScanoutConfigurationEx)] - public delegate Status NvAPI_GPU_GetScanOutConfigurationEx( - [In] uint displayId, - [In] [Accepts(typeof(ScanOutInformationV1))] - ValueTypeReference scanOutInformation - ); - - [FunctionId(FunctionId.NvAPI_GPU_GetScanoutIntensityState)] - public delegate Status NvAPI_GPU_GetScanOutIntensityState( - [In] uint displayId, - [In] [Accepts(typeof(ScanOutIntensityStateV1))] - ValueTypeReference scanOutIntensityState - ); - - [FunctionId(FunctionId.NvAPI_GPU_GetScanoutWarpingState)] - public delegate Status NvAPI_GPU_GetScanOutWarpingState( - [In] uint displayId, - [In] [Accepts(typeof(ScanOutWarpingStateV1))] - ValueTypeReference scanOutWarpingState - ); - - [FunctionId(FunctionId.NvAPI_GPU_SetScanoutCompositionParameter)] - public delegate Status NvAPI_GPU_SetScanOutCompositionParameter( - [In] uint displayId, - [In] ScanOutCompositionParameter parameter, - [In] ScanOutCompositionParameterValue parameterValue, - [In] ref float container - ); - - [FunctionId(FunctionId.NvAPI_GPU_SetScanoutIntensity)] - public delegate Status NvAPI_GPU_SetScanOutIntensity( - [In] uint displayId, - [In] [Accepts(typeof(ScanOutIntensityV2), typeof(ScanOutIntensityV1))] - ValueTypeReference scanOutIntensityData, - [Out] out int isSticky - ); - - [FunctionId(FunctionId.NvAPI_GPU_SetScanoutWarping)] - public delegate Status NvAPI_GPU_SetScanOutWarping( - [In] uint displayId, - [In] [Accepts(typeof(ScanOutWarpingV1))] - ValueTypeReference scanOutWarping, - [In] [Out] ref int maximumNumberOfVertices, - [Out] out int isSticky - ); - - [FunctionId(FunctionId.NvAPI_SetDVCLevel)] - public delegate Status NvAPI_SetDVCLevel( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] int dvcLevel - ); - - [FunctionId(FunctionId.NvAPI_SetDVCLevelEx)] - public delegate Status NvAPI_SetDVCLevelEx( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] [Accepts(typeof(PrivateDisplayDVCInfoEx))] - ValueTypeReference dvcInfo - ); - - [FunctionId(FunctionId.NvAPI_SetHUEAngle)] - public delegate Status NvAPI_SetHUEAngle( - [In] DisplayHandle displayHandle, - [In] OutputId displayId, - [In] int hueAngle - ); - - [FunctionId(FunctionId.NvAPI_SetRefreshRateOverride)] - public delegate Status NvAPI_SetRefreshRateOverride( - [In] DisplayHandle displayHandle, - [In] OutputId outputMask, - [In] float refreshRate, - [In] uint isDeferred - ); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/GPU.cs b/app/NvAPIWrapper/Native/Delegates/GPU.cs deleted file mode 100644 index a199f35c..00000000 --- a/app/NvAPIWrapper/Native/Delegates/GPU.cs +++ /dev/null @@ -1,726 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -// ReSharper disable InconsistentNaming - -namespace NvAPIWrapper.Native.Delegates -{ - internal static class GPU - { - [FunctionId(FunctionId.NvAPI_EnumLogicalGPUs)] - public delegate Status NvAPI_EnumLogicalGPUs( - [In] [Out] [MarshalAs(UnmanagedType.LPArray, SizeConst = LogicalGPUHandle.MaxLogicalGPUs)] - LogicalGPUHandle[] - gpuHandles, - [Out] out uint gpuCount); - - [FunctionId(FunctionId.NvAPI_EnumPhysicalGPUs)] - public delegate Status NvAPI_EnumPhysicalGPUs( - [In] [Out] [MarshalAs(UnmanagedType.LPArray, SizeConst = PhysicalGPUHandle.MaxPhysicalGPUs)] - PhysicalGPUHandle[] - gpuHandles, - [Out] out uint gpuCount); - - [FunctionId(FunctionId.NvAPI_EnumTCCPhysicalGPUs)] - public delegate Status NvAPI_EnumTCCPhysicalGPUs( - [In] [Out] [MarshalAs(UnmanagedType.LPArray, SizeConst = PhysicalGPUHandle.MaxPhysicalGPUs)] - PhysicalGPUHandle[] - gpuHandles, - [Out] out uint gpuCount); - - [FunctionId(FunctionId.NvAPI_GetDriverModel)] - public delegate Status NvAPI_GetDriverModel( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint model); - - [FunctionId(FunctionId.NvAPI_GetGPUIDfromPhysicalGPU)] - public delegate Status NvAPI_GetGPUIDFromPhysicalGPU( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint gpuId); - - [FunctionId(FunctionId.NvAPI_GetLogicalGPUFromDisplay)] - public delegate Status NvAPI_GetLogicalGPUFromDisplay( - [In] DisplayHandle displayHandle, - [Out] out LogicalGPUHandle gpuHandle); - - [FunctionId(FunctionId.NvAPI_GetLogicalGPUFromPhysicalGPU)] - public delegate Status NvAPI_GetLogicalGPUFromPhysicalGPU( - [In] PhysicalGPUHandle physicalGPUHandle, - [Out] out LogicalGPUHandle logicalGPUHandle); - - [FunctionId(FunctionId.NvAPI_GetPhysicalGPUFromGPUID)] - public delegate Status NvAPI_GetPhysicalGPUFromGPUID( - [In] uint gpuId, - [Out] out PhysicalGPUHandle physicalGpu); - - [FunctionId(FunctionId.NvAPI_GetPhysicalGPUFromUnAttachedDisplay)] - public delegate Status NvAPI_GetPhysicalGPUFromUnAttachedDisplay( - [In] UnAttachedDisplayHandle displayHandle, - [Out] out PhysicalGPUHandle gpuHandle); - - [FunctionId(FunctionId.NvAPI_GetPhysicalGPUsFromDisplay)] - public delegate Status NvAPI_GetPhysicalGPUsFromDisplay( - [In] DisplayHandle displayHandle, - [In] [Out] [MarshalAs(UnmanagedType.LPArray, SizeConst = PhysicalGPUHandle.MaxPhysicalGPUs)] - PhysicalGPUHandle[] - gpuHandles, - [Out] out uint gpuCount); - - [FunctionId(FunctionId.NvAPI_GetPhysicalGPUsFromLogicalGPU)] - public delegate Status NvAPI_GetPhysicalGPUsFromLogicalGPU( - [In] LogicalGPUHandle logicalGPUHandle, - [In] [Out] [MarshalAs(UnmanagedType.LPArray, SizeConst = PhysicalGPUHandle.MaxPhysicalGPUs)] - PhysicalGPUHandle[] - gpuHandles, - [Out] out uint gpuCount); - - [FunctionId(FunctionId.NvAPI_GPU_ClientFanCoolersGetControl)] - public delegate Status NvAPI_GPU_ClientFanCoolersGetControl( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateFanCoolersControlV1))] [In] - ValueTypeReference control); - - [FunctionId(FunctionId.NvAPI_GPU_ClientFanCoolersGetInfo)] - public delegate Status NvAPI_GPU_ClientFanCoolersGetInfo( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateFanCoolersInfoV1))] [In] - ValueTypeReference info); - - [FunctionId(FunctionId.NvAPI_GPU_ClientFanCoolersGetStatus)] - public delegate Status NvAPI_GPU_ClientFanCoolersGetStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateFanCoolersStatusV1))] [In] - ValueTypeReference status); - - [FunctionId(FunctionId.NvAPI_GPU_ClientFanCoolersSetControl)] - public delegate Status NvAPI_GPU_ClientFanCoolersSetControl( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateFanCoolersControlV1))] [In] - ValueTypeReference control); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumDevicesGetControl)] - public delegate Status NvAPI_GPU_ClientIlluminationDevicesGetControl( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationDeviceControlParametersV1))] [In] - ValueTypeReference illuminationDeviceControlInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumDevicesGetInfo)] - public delegate Status NvAPI_GPU_ClientIlluminationDevicesGetInfo( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationDeviceInfoParametersV1))] [In] - ValueTypeReference illuminationDevicesInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumDevicesSetControl)] - public delegate Status NvAPI_GPU_ClientIlluminationDevicesSetControl( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationDeviceControlParametersV1))] [In] - ValueTypeReference illuminationDeviceControlInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumZonesGetControl)] - public delegate Status NvAPI_GPU_ClientIlluminationZonesGetControl( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationZoneControlParametersV1))] [In] - ValueTypeReference illuminationZoneControlInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumZonesGetInfo)] - public delegate Status NvAPI_GPU_ClientIlluminationZonesGetInfo( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationZoneInfoParametersV1))] [In] - ValueTypeReference illuminationZoneInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientIllumZonesSetControl)] - public delegate Status NvAPI_GPU_ClientIlluminationZonesSetControl( - [In] PhysicalGPUHandle gpu, - [Accepts(typeof(IlluminationZoneControlParametersV1))] [In] - ValueTypeReference illuminationZoneControlInfo - ); - - [FunctionId(FunctionId.NvAPI_GPU_ClientPowerPoliciesGetInfo)] - public delegate Status NvAPI_GPU_ClientPowerPoliciesGetInfo( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivatePowerPoliciesInfoV1))] [In] - ValueTypeReference powerInfo); - - [FunctionId(FunctionId.NvAPI_GPU_ClientPowerPoliciesGetStatus)] - public delegate Status NvAPI_GPU_ClientPowerPoliciesGetStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivatePowerPoliciesStatusV1))] [In] - ValueTypeReference status); - - [FunctionId(FunctionId.NvAPI_GPU_ClientPowerPoliciesSetStatus)] - public delegate Status NvAPI_GPU_ClientPowerPoliciesSetStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivatePowerPoliciesStatusV1))] [In] - ValueTypeReference status); - - [FunctionId(FunctionId.NvAPI_GPU_ClientPowerTopologyGetStatus)] - public delegate Status NvAPI_GPU_ClientPowerTopologyGetStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivatePowerTopologiesStatusV1))] [In] - ValueTypeReference status); - - [FunctionId(FunctionId.NvAPI_GPU_EnableDynamicPstates)] - public delegate Status NvAPI_GPU_EnableDynamicPStates([In] PhysicalGPUHandle physicalGpu); - - [FunctionId(FunctionId.NvAPI_GPU_EnableOverclockedPstates)] - public delegate Status NvAPI_GPU_EnableOverclockedPStates([In] PhysicalGPUHandle physicalGpu); - - [FunctionId(FunctionId.NvAPI_GPU_GetActiveOutputs)] - public delegate Status NvAPI_GPU_GetActiveOutputs( - [In] PhysicalGPUHandle physicalGpu, - [Out] out OutputId outputMask); - - [FunctionId(FunctionId.NvAPI_GPU_GetAGPAperture)] - public delegate Status NvAPI_GPU_GetAGPAperture( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint size); - - [FunctionId(FunctionId.NvAPI_GPU_GetAllClockFrequencies)] - public delegate Status NvAPI_GPU_GetAllClockFrequencies( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(ClockFrequenciesV3), typeof(ClockFrequenciesV2), typeof(ClockFrequenciesV1))] - ValueTypeReference nvClocks); - - [FunctionId(FunctionId.NvAPI_GPU_GetAllDisplayIds)] - public delegate Status NvAPI_GPU_GetAllDisplayIds( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(DisplayIdsV2))] [In] [Out] - ValueTypeArray pDisplayIds, - [In] [Out] ref uint displayIdCount); - - [FunctionId(FunctionId.NvAPI_GPU_GetArchInfo)] - public delegate Status NvAPI_GPU_GetArchInfo( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateArchitectInfoV2))] [In] - ValueTypeReference info); - - [FunctionId(FunctionId.NvAPI_GPU_GetBoardInfo)] - public delegate Status NvAPI_GPU_GetBoardInfo( - [In] PhysicalGPUHandle physicalGpu, - [Out] [In] ref BoardInfo info); - - [FunctionId(FunctionId.NvAPI_GPU_GetBusId)] - public delegate Status NvAPI_GPU_GetBusId( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint gpuBusId); - - [FunctionId(FunctionId.NvAPI_GPU_GetBusSlotId)] - public delegate Status NvAPI_GPU_GetBusSlotId( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint gpuBusSlotId); - - [FunctionId(FunctionId.NvAPI_GPU_GetBusType)] - public delegate Status NvAPI_GPU_GetBusType( - [In] PhysicalGPUHandle physicalGpu, - [Out] out GPUBusType gpuBusType); - - [FunctionId(FunctionId.NvAPI_GPU_GetClockBoostLock)] - public delegate Status NvAPI_GPU_GetClockBoostLock( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostLockV2))] - ValueTypeReference clockLocks); - - [FunctionId(FunctionId.NvAPI_GPU_GetClockBoostMask)] - public delegate Status NvAPI_GPU_GetClockBoostMask( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostMasksV1))] - ValueTypeReference clockMasks); - - [FunctionId(FunctionId.NvAPI_GPU_GetClockBoostRanges)] - public delegate Status NvAPI_GPU_GetClockBoostRanges( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostRangesV1))] - ValueTypeReference clockRanges); - - [FunctionId(FunctionId.NvAPI_GPU_GetClockBoostTable)] - public delegate Status NvAPI_GPU_GetClockBoostTable( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostTableV1))] - ValueTypeReference boostTable); - - [FunctionId(FunctionId.NvAPI_GPU_GetConnectedDisplayIds)] - public delegate Status NvAPI_GPU_GetConnectedDisplayIds( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(DisplayIdsV2))] [In] [Out] - ValueTypeArray pDisplayIds, - [In] [Out] ref uint displayIdCount, - [In] ConnectedIdsFlag flags); - - [FunctionId(FunctionId.NvAPI_GPU_GetCoolerPolicyTable)] - public delegate Status NvAPI_GPU_GetCoolerPolicyTable( - [In] PhysicalGPUHandle physicalGpu, - [In] uint index, - [In] [Accepts(typeof(PrivateCoolerPolicyTableV1))] - ValueTypeReference coolerPolicyTable, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetCoolerSettings)] - public delegate Status NvAPI_GPU_GetCoolerSettings( - [In] PhysicalGPUHandle physicalGpu, - [In] CoolerTarget coolerIndex, - [In] [Accepts(typeof(PrivateCoolerSettingsV1))] - ValueTypeReference coolerSettings); - - [FunctionId(FunctionId.NvAPI_GPU_GetCoreVoltageBoostPercent)] - public delegate Status NvAPI_GPU_GetCoreVoltageBoostPercent( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateVoltageBoostPercentV1))] - ValueTypeReference voltageBoostPercent); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentAGPRate)] - public delegate Status NvAPI_GPU_GetCurrentAGPRate( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint rate); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentFanSpeedLevel)] - public delegate Status NvAPI_GPU_GetCurrentFanSpeedLevel( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint fanLevel); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentPCIEDownstreamWidth)] - public delegate Status NvAPI_GPU_GetCurrentPCIEDownstreamWidth( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint width); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentPstate)] - public delegate Status NvAPI_GPU_GetCurrentPState( - [In] PhysicalGPUHandle physicalGpu, - [Out] out PerformanceStateId performanceStateId); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentThermalLevel)] - public delegate Status NvAPI_GPU_GetCurrentThermalLevel( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint thermalLevel); - - [FunctionId(FunctionId.NvAPI_GPU_GetCurrentVoltage)] - public delegate Status NvAPI_GPU_GetCurrentVoltage( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateVoltageStatusV1))] - ValueTypeReference voltageStatus); - - [FunctionId(FunctionId.NvAPI_GPU_GetDynamicPstatesInfoEx)] - public delegate Status NvAPI_GPU_GetDynamicPStatesInfoEx( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(DynamicPerformanceStatesInfoV1))] - ValueTypeReference performanceStatesInfoEx); - - [FunctionId(FunctionId.NvAPI_GPU_GetECCConfigurationInfo)] - public delegate Status NvAPI_GPU_GetECCConfigurationInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(ECCConfigurationInfoV1))] - ValueTypeReference eccConfigurationInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetECCErrorInfo)] - public delegate Status NvAPI_GPU_GetECCErrorInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(ECCErrorInfoV1))] ValueTypeReference eccErrorInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetECCStatusInfo)] - public delegate Status NvAPI_GPU_GetECCStatusInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(ECCStatusInfoV1))] - ValueTypeReference eccStatusInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetEDID)] - public delegate Status NvAPI_GPU_GetEDID( - [In] PhysicalGPUHandle physicalGpu, - [In] OutputId outputId, - [Accepts(typeof(EDIDV3), typeof(EDIDV2), typeof(EDIDV1))] [In] - ValueTypeReference edid); - - [FunctionId(FunctionId.NvAPI_GPU_GetFBWidthAndLocation)] - public delegate Status NvAPI_GPU_GetFBWidthAndLocation( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint width, - [Out] out uint location); - - [FunctionId(FunctionId.NvAPI_GPU_GetFoundry)] - public delegate Status NvAPI_GPU_GetFoundry( - [In] PhysicalGPUHandle physicalGpu, - [Out] out GPUFoundry pFoundry); - - [FunctionId(FunctionId.NvAPI_GPU_GetFullName)] - public delegate Status NvAPI_GPU_GetFullName( - [In] PhysicalGPUHandle physicalGpu, - [Out] out ShortString name); - - [FunctionId(FunctionId.NvAPI_GPU_GetGpuCoreCount)] - public delegate Status NvAPI_GPU_GetGpuCoreCount( - [In] PhysicalGPUHandle gpuHandle, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetGPUType)] - public delegate Status NvAPI_GPU_GetGPUType( - [In] PhysicalGPUHandle physicalGpu, - [Out] out GPUType gpuType); - - [FunctionId(FunctionId.NvAPI_GPU_GetIllumination)] - public delegate Status NvAPI_GPU_GetIllumination( - [Accepts(typeof(GetIlluminationParameterV1))] [In] - ValueTypeReference illuminationInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetIRQ)] - public delegate Status NvAPI_GPU_GetIRQ( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint gpuIRQ); - - [FunctionId(FunctionId.NvAPI_GPU_GetLogicalFBWidthAndLocation)] - public delegate Status NvAPI_GPU_GetLogicalFBWidthAndLocation( - [In] LogicalGPUHandle logicalGpu, - [Out] out uint width, - [Out] out uint location); - - [FunctionId(FunctionId.NvAPI_GPU_GetMemoryInfo)] - public delegate Status NvAPI_GPU_GetMemoryInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] - [Accepts(typeof(DisplayDriverMemoryInfoV3), typeof(DisplayDriverMemoryInfoV2), - typeof(DisplayDriverMemoryInfoV1))] - ValueTypeReference memoryInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetOutputType)] - public delegate Status NvAPI_GPU_GetOutputType( - [In] PhysicalGPUHandle physicalGpu, - [In] uint outputId, - [Out] out OutputType outputType); - - - [FunctionId(FunctionId.NvAPI_GPU_GetPartitionCount)] - public delegate Status NvAPI_GPU_GetPartitionCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetPCIEInfo)] - public delegate Status NvAPI_GPU_GetPCIEInfo( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivatePCIeInfoV2))] [In] - ValueTypeReference pcieInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetPCIIdentifiers)] - public delegate Status NvAPI_GPU_GetPCIIdentifiers( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint deviceId, - [Out] out uint subSystemId, - [Out] out uint revisionId, - [Out] out uint extDeviceId); - - [FunctionId(FunctionId.NvAPI_GPU_GetPerfDecreaseInfo)] - public delegate Status NvAPI_GPU_GetPerfDecreaseInfo( - [In] PhysicalGPUHandle gpu, - [Out] out PerformanceDecreaseReason performanceDecreaseReason); - - [FunctionId(FunctionId.NvAPI_GPU_GetPhysicalFrameBufferSize)] - public delegate Status NvAPI_GPU_GetPhysicalFrameBufferSize( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint size); - - [FunctionId(FunctionId.NvAPI_GPU_GetPstates20)] - public delegate Status NvAPI_GPU_GetPStates20( - [In] PhysicalGPUHandle physicalGpu, - [Accepts( - typeof(PerformanceStates20InfoV1), - typeof(PerformanceStates20InfoV2), - typeof(PerformanceStates20InfoV3) - )] - [In] - ValueTypeReference performanceStatesInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetPstatesInfoEx)] - public delegate Status NvAPI_GPU_GetPStatesInfoEx( - [In] PhysicalGPUHandle physicalGpu, - [Accepts( - typeof(PerformanceStatesInfoV3), - typeof(PerformanceStatesInfoV2), - typeof(PerformanceStatesInfoV1) - )] - [In] - ValueTypeReference performanceStatesInfo, - [In] GetPerformanceStatesInfoFlags flags); - - [FunctionId(FunctionId.NvAPI_GPU_GetQuadroStatus)] - public delegate Status NvAPI_GPU_GetQuadroStatus( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint isQuadro); - - [FunctionId(FunctionId.NvAPI_GPU_GetRamBankCount)] - public delegate Status NvAPI_GPU_GetRamBankCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetRamBusWidth)] - public delegate Status NvAPI_GPU_GetRamBusWidth( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint busWidth); - - [FunctionId(FunctionId.NvAPI_GPU_GetRamMaker)] - public delegate Status NvAPI_GPU_GetRamMaker( - [In] PhysicalGPUHandle physicalGpu, - [Out] out GPUMemoryMaker maker); - - [FunctionId(FunctionId.NvAPI_GPU_GetRamType)] - public delegate Status NvAPI_GPU_GetRamType( - [In] PhysicalGPUHandle physicalGpu, - [Out] out GPUMemoryType type); - - [FunctionId(FunctionId.NvAPI_GPU_GetROPCount)] - public delegate Status NvAPI_GPU_GetROPCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetShaderPipeCount)] - public delegate Status NvAPI_GPU_GetShaderPipeCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetShaderSubPipeCount)] - public delegate Status NvAPI_GPU_GetShaderSubPipeCount( - [In] PhysicalGPUHandle gpuHandle, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetShortName)] - public delegate Status NvAPI_GPU_GetShortName( - [In] PhysicalGPUHandle physicalGpu, - [Out] out ShortString name); - - [FunctionId(FunctionId.NvAPI_GPU_GetSystemType)] - public delegate Status NvAPI_GPU_GetSystemType( - [In] PhysicalGPUHandle physicalGpu, - [Out] out SystemType systemType); - - [FunctionId(FunctionId.NvAPI_GPU_GetTachReading)] - public delegate Status NvAPI_GPU_GetTachReading( - [In] PhysicalGPUHandle gpuHandle, - [Out] out uint value); - - [FunctionId(FunctionId.NvAPI_GPU_GetThermalPoliciesInfo)] - public delegate Status NvAPI_GPU_GetThermalPoliciesInfo( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateThermalPoliciesInfoV2))] [In] - ValueTypeReference info); - - [FunctionId(FunctionId.NvAPI_GPU_GetThermalPoliciesStatus)] - public delegate Status NvAPI_GPU_GetThermalPoliciesStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateThermalPoliciesStatusV2))] [In] - ValueTypeReference info); - - [FunctionId(FunctionId.NvAPI_GPU_GetThermalSettings)] - public delegate Status NvAPI_GPU_GetThermalSettings( - [In] PhysicalGPUHandle physicalGpu, - [In] ThermalSettingsTarget sensorIndex, - [In] [Accepts(typeof(ThermalSettingsV2), typeof(ThermalSettingsV1))] - ValueTypeReference thermalSettings); - - [FunctionId(FunctionId.NvAPI_GPU_GetTotalSMCount)] - public delegate Status NvAPI_GPU_GetTotalSMCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetTotalSPCount)] - public delegate Status NvAPI_GPU_GetTotalSPCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetTotalTPCCount)] - public delegate Status NvAPI_GPU_GetTotalTPCCount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_GetUsages)] - public delegate Status NvAPI_GPU_GetUsages( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateUsagesInfoV1))] - ValueTypeReference usageInfo); - - [FunctionId(FunctionId.NvAPI_GPU_GetVbiosOEMRevision)] - public delegate Status NvAPI_GPU_GetVbiosOEMRevision( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint biosOEMRevision); - - [FunctionId(FunctionId.NvAPI_GPU_GetVbiosRevision)] - public delegate Status NvAPI_GPU_GetVbiosRevision( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint biosRevision); - - [FunctionId(FunctionId.NvAPI_GPU_GetVbiosVersionString)] - public delegate Status NvAPI_GPU_GetVbiosVersionString( - [In] PhysicalGPUHandle physicalGpu, - [Out] out ShortString biosVersion); - - [FunctionId(FunctionId.NvAPI_GPU_GetVFPCurve)] - public delegate Status NvAPI_GPU_GetVFPCurve( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateVFPCurveV1))] - ValueTypeReference vfpCurve); - - [FunctionId(FunctionId.NvAPI_GPU_GetVirtualFrameBufferSize)] - public delegate Status NvAPI_GPU_GetVirtualFrameBufferSize( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint size); - - [FunctionId(FunctionId.NvAPI_GPU_GetVPECount)] - public delegate Status NvAPI_GPU_GetVPECount( - [In] PhysicalGPUHandle physicalGpu, - [Out] out uint count); - - [FunctionId(FunctionId.NvAPI_GPU_PerfPoliciesGetInfo)] - public delegate Status NvAPI_GPU_PerfPoliciesGetInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivatePerformanceInfoV1))] - ValueTypeReference performanceInfo); - - [FunctionId(FunctionId.NvAPI_GPU_PerfPoliciesGetStatus)] - public delegate Status NvAPI_GPU_PerfPoliciesGetStatus( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivatePerformanceStatusV1))] - ValueTypeReference performanceStatus); - - [FunctionId(FunctionId.NvAPI_GPU_QueryActiveApps)] - public delegate Status NvAPI_GPU_QueryActiveApps( - [In] PhysicalGPUHandle gpu, - [In] [Accepts(typeof(PrivateActiveApplicationV2))] - ValueTypeArray applications, - [In] [Out] ref uint numberOfApplications - ); - - - [FunctionId(FunctionId.NvAPI_GPU_QueryIlluminationSupport)] - public delegate Status NvAPI_GPU_QueryIlluminationSupport( - [Accepts(typeof(QueryIlluminationSupportParameterV1))] [In] - ValueTypeReference illuminationSupportInfo); - - [FunctionId(FunctionId.NvAPI_GPU_ResetECCErrorInfo)] - public delegate Status NvAPI_GPU_ResetECCErrorInfo( - [In] PhysicalGPUHandle physicalGpu, - [In] byte resetCurrent, - [In] byte resetAggregated - ); - - [FunctionId(FunctionId.NvAPI_GPU_RestoreCoolerPolicyTable)] - public delegate Status NvAPI_GPU_RestoreCoolerPolicyTable( - [In] PhysicalGPUHandle physicalGpu, - [In] uint[] indexes, - [In] uint indexesCount, - [In] CoolerPolicy policy); - - [FunctionId(FunctionId.NvAPI_GPU_RestoreCoolerSettings)] - public delegate Status NvAPI_GPU_RestoreCoolerSettings( - [In] PhysicalGPUHandle physicalGpu, - [In] uint[] indexes, - [In] uint indexesCount); - - [FunctionId(FunctionId.NvAPI_GPU_SetClockBoostLock)] - public delegate Status NvAPI_GPU_SetClockBoostLock( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostLockV2))] - ValueTypeReference clockLocks); - - [FunctionId(FunctionId.NvAPI_GPU_SetClockBoostTable)] - public delegate Status NvAPI_GPU_SetClockBoostTable( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateClockBoostTableV1))] - ValueTypeReference boostTable); - - [FunctionId(FunctionId.NvAPI_GPU_SetCoolerLevels)] - public delegate Status NvAPI_GPU_SetCoolerLevels( - [In] PhysicalGPUHandle physicalGpu, - [In] uint index, - [In] [Accepts(typeof(PrivateCoolerLevelsV1))] - ValueTypeReference coolerLevels, - [In] uint count); - - [FunctionId(FunctionId.NvAPI_GPU_SetCoolerPolicyTable)] - public delegate Status NvAPI_GPU_SetCoolerPolicyTable( - [In] PhysicalGPUHandle physicalGpu, - [In] uint index, - [In] [Accepts(typeof(PrivateCoolerPolicyTableV1))] - ValueTypeReference coolerLevels, - [In] uint count); - - [FunctionId(FunctionId.NvAPI_GPU_SetCoreVoltageBoostPercent)] - public delegate Status NvAPI_GPU_SetCoreVoltageBoostPercent( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(PrivateVoltageBoostPercentV1))] - ValueTypeReference voltageBoostPercent); - - [FunctionId(FunctionId.NvAPI_GPU_SetECCConfiguration)] - public delegate Status NvAPI_GPU_SetECCConfiguration( - [In] PhysicalGPUHandle physicalGpu, - [In] byte isEnable, - [In] byte isEnableImmediately - ); - - [FunctionId(FunctionId.NvAPI_GPU_SetEDID)] - public delegate Status NvAPI_GPU_SetEDID( - [In] PhysicalGPUHandle physicalGpu, - [In] uint outputId, - [Accepts(typeof(EDIDV3), typeof(EDIDV2), typeof(EDIDV1))] [In] - ValueTypeReference edid); - - - [FunctionId(FunctionId.NvAPI_GPU_SetIllumination)] - public delegate Status NvAPI_GPU_SetIllumination( - [Accepts(typeof(SetIlluminationParameterV1))] [In] - ValueTypeReference illuminationInfo); - - [FunctionId(FunctionId.NvAPI_GPU_SetPstates20)] - public delegate Status NvAPI_GPU_SetPStates20( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PerformanceStates20InfoV3), typeof(PerformanceStates20InfoV2), - typeof(PerformanceStates20InfoV1))] - [In] - ValueTypeReference performanceStatesInfo); - - [FunctionId(FunctionId.NvAPI_GPU_SetThermalPoliciesStatus)] - public delegate Status NvAPI_GPU_SetThermalPoliciesStatus( - [In] PhysicalGPUHandle physicalGpu, - [Accepts(typeof(PrivateThermalPoliciesStatusV2))] [In] - ValueTypeReference info); - - [FunctionId(FunctionId.NvAPI_GPU_ValidateOutputCombination)] - public delegate Status NvAPI_GPU_ValidateOutputCombination( - [In] PhysicalGPUHandle physicalGpu, - [In] OutputId outputMask); - - [FunctionId(FunctionId.NvAPI_I2CRead)] - public delegate Status NvAPI_I2CRead( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(I2CInfoV3), typeof(I2CInfoV2))] ValueTypeReference i2cInfo - ); - - [FunctionId(FunctionId.NvAPI_I2CWrite)] - public delegate Status NvAPI_I2CWrite( - [In] PhysicalGPUHandle physicalGpu, - [In] [Accepts(typeof(I2CInfoV3), typeof(I2CInfoV2))] ValueTypeReference i2cInfo - ); - - [FunctionId(FunctionId.NvAPI_SYS_GetDisplayIdFromGpuAndOutputId)] - public delegate Status NvAPI_SYS_GetDisplayIdFromGpuAndOutputId( - [In] PhysicalGPUHandle gpu, - [In] OutputId outputId, - [Out] out uint displayId); - - [FunctionId(FunctionId.NvAPI_SYS_GetGpuAndOutputIdFromDisplayId)] - public delegate Status NvAPI_SYS_GetGpuAndOutputIdFromDisplayId( - [In] uint displayId, - [Out] out PhysicalGPUHandle gpu, - [Out] out OutputId outputId); - - [FunctionId(FunctionId.NvAPI_SYS_GetPhysicalGpuFromDisplayId)] - public delegate Status NvAPI_SYS_GetPhysicalGpuFromDisplayId( - [In] uint displayId, - [Out] out PhysicalGPUHandle gpu); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/General.cs b/app/NvAPIWrapper/Native/Delegates/General.cs deleted file mode 100644 index ab5e2cd8..00000000 --- a/app/NvAPIWrapper/Native/Delegates/General.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -// ReSharper disable InconsistentNaming - -namespace NvAPIWrapper.Native.Delegates -{ - internal static class General - { - [FunctionId(FunctionId.NvAPI_GetErrorMessage)] - public delegate Status NvAPI_GetErrorMessage([In] Status status, out ShortString message); - - [FunctionId(FunctionId.NvAPI_GetInterfaceVersionString)] - public delegate Status NvAPI_GetInterfaceVersionString(out ShortString version); - - [FunctionId(FunctionId.NvAPI_Initialize)] - public delegate Status NvAPI_Initialize(); - - - [FunctionId(FunctionId.NvAPI_RestartDisplayDriver)] - public delegate Status NvAPI_RestartDisplayDriver(); - - [FunctionId(FunctionId.NvAPI_SYS_GetChipSetInfo)] - public delegate Status NvAPI_SYS_GetChipSetInfo( - [In] [Accepts(typeof(ChipsetInfoV4), typeof(ChipsetInfoV3), typeof(ChipsetInfoV2), typeof(ChipsetInfoV1))] - ValueTypeReference chipsetInfo); - - [FunctionId(FunctionId.NvAPI_SYS_GetDriverAndBranchVersion)] - public delegate Status NvAPI_SYS_GetDriverAndBranchVersion( - out uint driverVersion, - out ShortString buildBranchString); - - [FunctionId(FunctionId.NvAPI_SYS_GetLidAndDockInfo)] - public delegate Status NvAPI_SYS_GetLidAndDockInfo([In] [Out] ref LidDockParameters lidAndDock); - - [FunctionId(FunctionId.NvAPI_Unload)] - public delegate Status NvAPI_Unload(); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/Mosaic.cs b/app/NvAPIWrapper/Native/Delegates/Mosaic.cs deleted file mode 100644 index e323e744..00000000 --- a/app/NvAPIWrapper/Native/Delegates/Mosaic.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Mosaic; -using NvAPIWrapper.Native.Mosaic.Structures; - -// ReSharper disable InconsistentNaming - -namespace NvAPIWrapper.Native.Delegates -{ - internal static class Mosaic - { - [FunctionId(FunctionId.NvAPI_Mosaic_EnableCurrentTopo)] - public delegate Status NvAPI_Mosaic_EnableCurrentTopo(uint enable); - - [FunctionId(FunctionId.NvAPI_Mosaic_EnumDisplayGrids)] - public delegate Status NvAPI_Mosaic_EnumDisplayGrids( - [Accepts(typeof(GridTopologyV2), typeof(GridTopologyV1))] [In] [Out] - ValueTypeArray gridTopology, - [In] [Out] ref uint gridCount); - - [FunctionId(FunctionId.NvAPI_Mosaic_EnumDisplayModes)] - public delegate Status NvAPI_Mosaic_EnumDisplayModes( - [Accepts(typeof(GridTopologyV2), typeof(GridTopologyV1))] [In] - ValueTypeReference gridTopology, - [Accepts(typeof(DisplaySettingsV2), typeof(DisplaySettingsV1))] [In] [Out] - ValueTypeArray - displaysSettings, - [In] [Out] ref uint displaysCount); - - [FunctionId(FunctionId.NvAPI_Mosaic_GetCurrentTopo)] - public delegate Status NvAPI_Mosaic_GetCurrentTopo( - [In] [Out] ref TopologyBrief topoBrief, - [Accepts(typeof(DisplaySettingsV2), typeof(DisplaySettingsV1))] [In] [Out] - ValueTypeReference displaySetting, - [Out] out int overlapX, - [Out] out int overlapY); - - [FunctionId(FunctionId.NvAPI_Mosaic_GetOverlapLimits)] - public delegate Status NvAPI_Mosaic_GetOverlapLimits( - [In] TopologyBrief topoBrief, - [Accepts(typeof(DisplaySettingsV2), typeof(DisplaySettingsV1))] [In] - ValueTypeReference displaySetting, - [Out] out int minOverlapX, - [Out] out int maxOverlapX, - [Out] out int minOverlapY, - [Out] out int maxOverlapY); - - [FunctionId(FunctionId.NvAPI_Mosaic_GetSupportedTopoInfo)] - public delegate Status NvAPI_Mosaic_GetSupportedTopoInfo( - [Accepts(typeof(SupportedTopologiesInfoV2), typeof(SupportedTopologiesInfoV1))] [In] [Out] - ValueTypeReference - supportedTopoInfo, - TopologyType topologyType); - - [FunctionId(FunctionId.NvAPI_Mosaic_GetTopoGroup)] - public delegate Status NvAPI_Mosaic_GetTopoGroup( - [In] TopologyBrief topoBrief, - [In] [Out] ref TopologyGroup topoGroup); - - [FunctionId(FunctionId.NvAPI_Mosaic_SetCurrentTopo)] - public delegate Status NvAPI_Mosaic_SetCurrentTopo( - [In] TopologyBrief topoBrief, - [Accepts(typeof(DisplaySettingsV2), typeof(DisplaySettingsV1))] [In] - ValueTypeReference displaySetting, - int overlapX, - int overlapY, - uint enable - ); - - [FunctionId(FunctionId.NvAPI_Mosaic_SetDisplayGrids)] - public delegate Status NvAPI_Mosaic_SetDisplayGrids( - [Accepts(typeof(GridTopologyV2), typeof(GridTopologyV1))] [In] - ValueTypeArray gridTopologies, - [In] uint gridCount, - [In] SetDisplayTopologyFlag setTopoFlags); - - [FunctionId(FunctionId.NvAPI_Mosaic_ValidateDisplayGrids)] - public delegate Status NvAPI_Mosaic_ValidateDisplayGrids( - [In] SetDisplayTopologyFlag setTopoFlags, - [Accepts(typeof(GridTopologyV2), typeof(GridTopologyV1))] [In] - ValueTypeArray gridTopologies, - [In] [Out] ref DisplayTopologyStatus[] topoStatuses, - [In] uint gridCount); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Delegates/Stereo.cs b/app/NvAPIWrapper/Native/Delegates/Stereo.cs deleted file mode 100644 index e37a7908..00000000 --- a/app/NvAPIWrapper/Native/Delegates/Stereo.cs +++ /dev/null @@ -1,248 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Stereo; -using NvAPIWrapper.Native.Stereo.Structures; - -// ReSharper disable InconsistentNaming -namespace NvAPIWrapper.Native.Delegates -{ - internal static class Stereo - { - [FunctionId(FunctionId.NvAPI_D3D1x_CreateSwapChain)] - public delegate Status NvAPI_D3D1x_CreateSwapChain( - [In] StereoHandle stereoHandle, - [In] IntPtr dxgiSwapChainDescription, - [Out] out IntPtr dxgiSwapChain, - [In] StereoSwapChainMode mode - ); - - [FunctionId(FunctionId.NvAPI_D3D9_CreateSwapChain)] - public delegate Status NvAPI_D3D9_CreateSwapChain( - [In] StereoHandle stereoHandle, - [In] IntPtr d3dPresentParameters, - [Out] out IntPtr direct3DSwapChain9, - [In] StereoSwapChainMode mode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_Activate)] - public delegate Status NvAPI_Stereo_Activate( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_CaptureJpegImage)] - public delegate Status NvAPI_Stereo_CaptureJpegImage( - [In] StereoHandle stereoHandle, - [In] uint quality - ); - - [FunctionId(FunctionId.NvAPI_Stereo_CapturePngImage)] - public delegate Status NvAPI_Stereo_CapturePngImage( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_CreateConfigurationProfileRegistryKey)] - public delegate Status NvAPI_Stereo_CreateConfigurationProfileRegistryKey( - [In] StereoRegistryProfileType registryProfileType - ); - - [FunctionId(FunctionId.NvAPI_Stereo_CreateHandleFromIUnknown)] - public delegate Status NvAPI_Stereo_CreateHandleFromIUnknown( - [In] IntPtr d3dDevice, - [Out] out StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_Deactivate)] - public delegate Status NvAPI_Stereo_Deactivate( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_Debug_WasLastDrawStereoized)] - public delegate Status NvAPI_Stereo_Debug_WasLastDrawStereoized( - [In] StereoHandle stereoHandle, - [Out] out byte wasStereo - ); - - [FunctionId(FunctionId.NvAPI_Stereo_DecreaseConvergence)] - public delegate Status NvAPI_Stereo_DecreaseConvergence( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_DecreaseSeparation)] - public delegate Status NvAPI_Stereo_DecreaseSeparation( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_DeleteConfigurationProfileRegistryKey)] - public delegate Status NvAPI_Stereo_DeleteConfigurationProfileRegistryKey( - [In] StereoRegistryProfileType registryProfileType - ); - - [FunctionId(FunctionId.NvAPI_Stereo_DeleteConfigurationProfileValue)] - public delegate Status NvAPI_Stereo_DeleteConfigurationProfileValue( - [In] StereoRegistryProfileType registryProfileType, - [In] StereoRegistryIdentification registryId - ); - - [FunctionId(FunctionId.NvAPI_Stereo_DestroyHandle)] - public delegate Status NvAPI_Stereo_DestroyHandle( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_Disable)] - public delegate Status NvAPI_Stereo_Disable(); - - [FunctionId(FunctionId.NvAPI_Stereo_Enable)] - public delegate Status NvAPI_Stereo_Enable(); - - - [FunctionId(FunctionId.NvAPI_Stereo_GetConvergence)] - public delegate Status NvAPI_Stereo_GetConvergence( - [In] StereoHandle stereoHandle, - [Out] out float convergence - ); - - [FunctionId(FunctionId.NvAPI_Stereo_GetDefaultProfile)] - public delegate Status NvAPI_Stereo_GetDefaultProfile( - [In] uint bufferSize, - [In] IntPtr stringBuffer, - [Out] out uint stringSize - ); - - [FunctionId(FunctionId.NvAPI_Stereo_GetEyeSeparation)] - public delegate Status NvAPI_Stereo_GetEyeSeparation( - [In] StereoHandle stereoHandle, - [Out] out float separation - ); - - [FunctionId(FunctionId.NvAPI_Stereo_GetFrustumAdjustMode)] - public delegate Status NvAPI_Stereo_GetFrustumAdjustMode( - [In] StereoHandle stereoHandle, - [Out] out StereoFrustumAdjustMode frustumAdjustMode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_GetSeparation)] - public delegate Status NvAPI_Stereo_GetSeparation( - [In] StereoHandle stereoHandle, - [Out] out float separationPercentage - ); - - - [FunctionId(FunctionId.NvAPI_Stereo_GetStereoSupport)] - public delegate Status NvAPI_Stereo_GetStereoSupport( - [In] IntPtr monitorHandle, - [In] [Accepts(typeof(StereoCapabilitiesV1))] - ValueTypeReference capabilities - ); - - [FunctionId(FunctionId.NvAPI_Stereo_GetSurfaceCreationMode)] - public delegate Status NvAPI_Stereo_GetSurfaceCreationMode( - [In] StereoHandle stereoHandle, - [Out] out StereoSurfaceCreateMode surfaceCreateMode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_IncreaseConvergence)] - public delegate Status NvAPI_Stereo_IncreaseConvergence( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_IncreaseSeparation)] - public delegate Status NvAPI_Stereo_IncreaseSeparation( - [In] StereoHandle stereoHandle - ); - - [FunctionId(FunctionId.NvAPI_Stereo_InitActivation)] - public delegate Status NvAPI_Stereo_InitActivation( - [In] StereoHandle stereoHandle, - [In] StereoActivationFlag flag - ); - - [FunctionId(FunctionId.NvAPI_Stereo_IsActivated)] - public delegate Status NvAPI_Stereo_IsActivated( - [In] StereoHandle stereoHandle, - [Out] out byte isStereoActive - ); - - [FunctionId(FunctionId.NvAPI_Stereo_IsEnabled)] - public delegate Status NvAPI_Stereo_IsEnabled([Out] out byte isEnable); - - [FunctionId(FunctionId.NvAPI_Stereo_IsWindowedModeSupported)] - public delegate Status NvAPI_Stereo_IsWindowedModeSupported([Out] out byte isEnable); - - [FunctionId(FunctionId.NvAPI_Stereo_ReverseStereoBlitControl)] - public delegate Status NvAPI_Stereo_ReverseStereoBlitControl( - [In] StereoHandle stereoHandle, - [In] byte turnOn - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetActiveEye)] - public delegate Status NvAPI_Stereo_SetActiveEye( - [In] StereoHandle stereoHandle, - [In] StereoActiveEye activeEye - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetConfigurationProfileValue)] - public delegate Status NvAPI_Stereo_SetConfigurationProfileValueFloat( - [In] StereoRegistryProfileType registryProfileType, - [In] StereoRegistryIdentification registryId, - [In] ref float value - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetConfigurationProfileValue)] - public delegate Status NvAPI_Stereo_SetConfigurationProfileValueInteger( - [In] StereoRegistryProfileType registryProfileType, - [In] StereoRegistryIdentification registryId, - [In] ref int value - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetConvergence)] - public delegate Status NvAPI_Stereo_SetConvergence( - [In] StereoHandle stereoHandle, - [In] float newConvergence - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetDefaultProfile)] - public delegate Status NvAPI_Stereo_SetDefaultProfile( - [In] [MarshalAs(UnmanagedType.LPStr)] string profileName - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetDriverMode)] - public delegate Status NvAPI_Stereo_SetDriverMode( - [In] StereoDriverMode driverMode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetFrustumAdjustMode)] - public delegate Status NvAPI_Stereo_SetFrustumAdjustMode( - [In] StereoHandle stereoHandle, - [In] StereoFrustumAdjustMode frustumAdjustMode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetNotificationMessage)] - public delegate Status NvAPI_Stereo_SetNotificationMessage( - [In] StereoHandle stereoHandle, - [In] ulong windowHandle, - [In] ulong messageId - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetSeparation)] - public delegate Status NvAPI_Stereo_SetSeparation( - [In] StereoHandle stereoHandle, - [In] float newSeparationPercentage - ); - - [FunctionId(FunctionId.NvAPI_Stereo_SetSurfaceCreationMode)] - public delegate Status NvAPI_Stereo_SetSurfaceCreationMode( - [In] StereoHandle stereoHandle, - [In] StereoSurfaceCreateMode newSurfaceCreateMode - ); - - [FunctionId(FunctionId.NvAPI_Stereo_Trigger_Activation)] - public delegate Status NvAPI_Stereo_Trigger_Activation( - [In] StereoHandle stereoHandle - ); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataColorimetry.cs b/app/NvAPIWrapper/Native/Display/ColorDataColorimetry.cs deleted file mode 100644 index e87908a7..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataColorimetry.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for color data color space - /// - public enum ColorDataColorimetry : uint - { - /// - /// RGB color space - /// - RGB = 0, - - /// - /// YCC601 color space - /// - YCC601, - - /// - /// YCC709 color space - /// - YCC709, - - /// - /// XVYCC601 color space - /// - XVYCC601, - - /// - /// XVYCC709 color space - /// - XVYCC709, - - /// - /// SYCC601 color space - /// - SYCC601, - - /// - /// ADOBEYCC601 color space - /// - ADOBEYCC601, - - /// - /// ADOBERGB color space - /// - ADOBERGB, - - /// - /// BT2020RGB color space - /// - BT2020RGB, - - /// - /// BT2020YCC color space - /// - BT2020YCC, - - /// - /// BT2020cYCC color space - /// - // ReSharper disable once InconsistentNaming - BT2020cYCC, - - /// - /// Default color space - /// - Default = 0xFE, - - /// - /// Automatically select color space - /// - Auto = 0xFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataCommand.cs b/app/NvAPIWrapper/Native/Display/ColorDataCommand.cs deleted file mode 100644 index cf1761f5..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataCommand.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the color data command - /// - public enum ColorDataCommand : uint - { - /// - /// Get the current color data - /// - Get = 1, - - /// - /// Set the current color data - /// - Set, - - /// - /// Check if the passed color data is supported - /// - IsSupportedColor, - - /// - /// Get the default color data - /// - GetDefault - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataDepth.cs b/app/NvAPIWrapper/Native/Display/ColorDataDepth.cs deleted file mode 100644 index e77eb89a..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataDepth.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the color data depth - /// - public enum ColorDataDepth : uint - { - /// - /// Default color depth meaning that the current setting should be kept - /// - Default = 0, - - /// - /// 6bit per color depth - /// - BPC6 = 1, - - /// - /// 8bit per color depth - /// - BPC8 = 2, - - /// - /// 10bit per color depth - /// - BPC10 = 3, - - /// - /// 12bit per color depth - /// - BPC12 = 4, - - /// - /// 16bit per color depth - /// - BPC16 = 5 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataDesktopDepth.cs b/app/NvAPIWrapper/Native/Display/ColorDataDesktopDepth.cs deleted file mode 100644 index 7d5673d1..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataDesktopDepth.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the color data desktop color depth - /// - public enum ColorDataDesktopDepth : uint - { - /// - /// Default color depth meaning that the current setting should be kept - /// - Default = 0x0, - - /// - /// 8bit per integer color component - /// - BPC8 = 0x1, - - /// - /// 10bit integer per color component - /// - BPC10 = 0x2, - - /// - /// 16bit float per color component - /// - BPC16Float = 0x3, - - /// - /// 16bit float per color component wide color gamut - /// - BPC16FloatWcg = 0x4, - - /// - /// 16bit float per color component HDR - /// - BPC16FloatHDR = 0x5 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataDynamicRange.cs b/app/NvAPIWrapper/Native/Display/ColorDataDynamicRange.cs deleted file mode 100644 index 16dee353..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataDynamicRange.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for color data dynamic range - /// - public enum ColorDataDynamicRange : uint - { - /// - /// VESA standard progress signal - /// - VESA = 0, - - /// - /// CEA interlaced signal - /// - CEA, - - /// - /// Automatically select the best value - /// - Auto - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataFormat.cs b/app/NvAPIWrapper/Native/Display/ColorDataFormat.cs deleted file mode 100644 index 42f26e27..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataFormat.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible color data color format values - /// - public enum ColorDataFormat : uint - { - /// - /// RGB color format - /// - RGB = 0, - - /// - /// YUV422 color format - /// - YUV422, - - /// - /// YUV444 color format - /// - YUV444, - - /// - /// YUV420 color format - /// - YUV420, - - /// - /// Default color format - /// - Default = 0xFE, - - /// - /// Automatically select the best color format - /// - Auto = 0xFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataHDRCommand.cs b/app/NvAPIWrapper/Native/Display/ColorDataHDRCommand.cs deleted file mode 100644 index 9cb1fd31..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataHDRCommand.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the HDR color data command - /// - public enum ColorDataHDRCommand : uint - { - /// - /// Get the current HDR color data - /// - Get = 0, - - /// - /// Set the current HDR color data - /// - Set = 1 - } -} diff --git a/app/NvAPIWrapper/Native/Display/ColorDataHDRMode.cs b/app/NvAPIWrapper/Native/Display/ColorDataHDRMode.cs deleted file mode 100644 index 7d49042d..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataHDRMode.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible color data HDR modes - /// - public enum ColorDataHDRMode : uint - { - /// - /// Turn off HDR. - /// - Off = 0, - - /// - /// Source: CCCS [a.k.a FP16 scRGB, linear, sRGB primaries, [-65504,0, 65504] range, RGB(1,1,1) = 80nits] - /// Output: UHDA HDR [a.k.a HDR10, RGB/YCC 10/12bpc ST2084(PQ) EOTF RGB(1,1,1) = 10000 nits, Rec2020 color primaries, - /// ST2086 static HDR metadata]. - /// This is the only supported production HDR mode. - /// - UHDA = 2, - - /// - /// Source: CCCS (a.k.a FP16 scRGB) - /// Output: EDR (Extended Dynamic Range) - HDR content is tone-mapped and gamut mapped to output on regular SDR display - /// set to max luminance ( ~300 nits ). - /// - [Obsolete("Do not use! Internal test mode only, to be removed.", false)] - EDR = 3, - - /// - /// Source: any - /// Output: SDR (Standard Dynamic Range), we continuously send SDR EOTF InfoFrame signaling, HDMI compliance testing. - /// - [Obsolete("Do not use! Internal test mode only, to be removed.", false)] - SDR = 4, - - /// - /// Source: HDR10 RGB 10bpc - /// Output: HDR10 RGB 10 colorDepth - signal UHDA HDR mode (PQ + Rec2020) to the sink but send source pixel values - /// unmodified (no PQ or Rec2020 conversions) - assumes source is already in HDR10 format. - /// - [Obsolete("Experimental mode only, not for production!", false)] - UHDAPassthrough = 5, - - /// - /// Source: CCCS (a.k.a FP16 scRGB) - /// Output: notebook HDR - /// - [Obsolete("Do not use! Internal test mode only, to be removed.", false)] - UHDANB = 6, - - /// - /// Source: RGB8 Dolby Vision encoded (12 colorDepth YCbCr422 packed into RGB8) - /// Output: Dolby Vision encoded : Application is to encoded frames in DV format and embed DV dynamic metadata as - /// described in Dolby Vision specification. - /// - [Obsolete("Experimental mode only, not for production!", false)] - DolbyVision = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorDataSelectionPolicy.cs b/app/NvAPIWrapper/Native/Display/ColorDataSelectionPolicy.cs deleted file mode 100644 index 86468b20..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorDataSelectionPolicy.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible values for the color data selection policy - /// - public enum ColorDataSelectionPolicy : uint - { - /// - /// Application or the Nvidia Control Panel user configuration are used to decide the best color format - /// - User = 0, - - /// - /// Driver or the Operating System decides the best color format - /// - BestQuality = 1, - - /// - /// Default value, - /// - Default = BestQuality, - - /// - /// Unknown policy - /// - Unknown = 0xFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ColorFormat.cs b/app/NvAPIWrapper/Native/Display/ColorFormat.cs deleted file mode 100644 index 56d436f9..00000000 --- a/app/NvAPIWrapper/Native/Display/ColorFormat.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible color formats - /// - public enum ColorFormat - { - /// - /// Unknown, driver will choose one automatically. - /// - Unknown = 0, - - /// - /// 8bpp mode - /// - P8 = 41, - - /// - /// 16bpp mode - /// - R5G6B5 = 23, - - /// - /// 32bpp mode - /// - A8R8G8B8 = 21, - - /// - /// 64bpp (floating point) - /// - A16B16G16R16F = 113 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/DisplayConfigFlags.cs b/app/NvAPIWrapper/Native/Display/DisplayConfigFlags.cs deleted file mode 100644 index f92ed18f..00000000 --- a/app/NvAPIWrapper/Native/Display/DisplayConfigFlags.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Display -{ - /// - /// Flags for applying settings, used by NvAPI_DISP_SetDisplayConfig() - /// - [Flags] - public enum DisplayConfigFlags - { - /// - /// None - /// - None = 0, - - /// - /// Do not apply - /// - ValidateOnly = 0x00000001, - - /// - /// Save to the persistence storage - /// - SaveToPersistence = 0x00000002, - - /// - /// Driver reload is permitted if necessary - /// - DriverReloadAllowed = 0x00000004, - - /// - /// Refresh OS mode list. - /// - ForceModeEnumeration = 0x00000008, - - /// - /// Tell OS to avoid optimizing CommitVidPn call during a modeset - /// - ForceCommitVideoPresentNetwork = 0x00000010 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/DisplayPortColorDepth.cs b/app/NvAPIWrapper/Native/Display/DisplayPortColorDepth.cs deleted file mode 100644 index a8ad307d..00000000 --- a/app/NvAPIWrapper/Native/Display/DisplayPortColorDepth.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible display port color depths - /// - public enum DisplayPortColorDepth : uint - { - /// - /// Default color depth - /// - Default = 0, - /// - /// 6 bit per color color depth - /// - BPC6, - /// - /// 8 bit per color color depth - /// - BPC8, - /// - /// 10 bit per color color depth - /// - BPC10, - /// - /// 12 bit per color color depth - /// - BPC12, - - /// - /// 16 bit per color color depth - /// - BPC16, - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/DisplayPortColorFormat.cs b/app/NvAPIWrapper/Native/Display/DisplayPortColorFormat.cs deleted file mode 100644 index 8ab13672..00000000 --- a/app/NvAPIWrapper/Native/Display/DisplayPortColorFormat.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible display port color formats - /// - public enum DisplayPortColorFormat : uint - { - /// - /// RGB color format - /// - RGB = 0, - - /// - /// YCbCr422 color format - /// - YCbCr422 = 1, - - /// - /// YCbCr444 color format - /// - YCbCr444 = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelAllocation.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelAllocation.cs deleted file mode 100644 index 0704a129..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelAllocation.cs +++ /dev/null @@ -1,300 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio channel allocations (speaker placements) - /// - public enum InfoFrameAudioChannelAllocation : uint - { - /// - /// [0] Empty [1] Empty [2] Empty [3] Empty [4] Empty [5] Empty [6] Front Right [7] Front Left - /// - FrFl = 0, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Empty [4] Empty [5] Low Frequency Effects [6] Front Right [7] Front Left - /// - LfeFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Empty [4] Front Center [5] Empty [6] Front Right [7] Front Left - /// - FcFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Empty [4] Front Center [5] Low Frequency Effects [6] Front Right [7] Front Left - /// - FcLfeFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Rear Center [4] Empty [5] Empty [6] Front Right [7] Front Left - /// - RcFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Rear Center [4] Empty [5] Low Frequency Effects [6] Front Right [7] Front Left - /// - RcLfeFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Rear Center [4] Front Center [5] Empty [6] Front Right [7] Front Left - /// - RcFcFrFl, - - /// - /// [0] Empty [1] Empty [2] Empty [3] Rear Center [4] Front Center [5] Low Frequency Effects [6] Front Right [7] Front - /// Left - /// - RcFcLfeFrFl, - - /// - /// [0] Empty [1] Empty [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right [7] Front Left - /// - RrRlFrFl, - - /// - /// [0] Empty [1] Empty [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects [6] Front Right [7] Front Left - /// - RrRlLfeFrFl, - - /// - /// [0] Empty [1] Empty [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] Front Left - /// - RrRlFcFrFl, - - /// - /// [0] Empty [1] Empty [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] Front Right [7] - /// Front Left - /// - RrRlFcLfeFrFl, - - /// - /// [0] Empty [1] Rear Center [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right [7] Front Left - /// - RcRrRlFrFl, - - /// - /// [0] Empty [1] Rear Center [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects [6] Front Right [7] - /// Front Left - /// - RcRrRlLfeFrFl, - - /// - /// [0] Empty [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] Front Left - /// - RcRrRlFcFrFl, - - /// - /// [0] Empty [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] Front Right - /// [7] Front Left - /// - RcRrRlFcLfeFrFl, - - /// - /// [0] Rear Right Of Center [1] Rear Left Of Center [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right - /// [7] Front Left - /// - RrcRlcRrRlFrFl, - - /// - /// [0] Rear Right Of Center [1] Rear Left Of Center [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - RrcRlcRrRlLfeFrFl, - - /// - /// [0] Rear Right Of Center [1] Rear Left Of Center [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front - /// Right [7] Front Left - /// - RrcRlcRrRlFcFrFl, - - /// - /// [0] Rear Right Of Center [1] Rear Left Of Center [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency - /// Effects [6] Front Right [7] Front Left - /// - RrcRlcRrRlFcLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Empty [4] Empty [5] Empty [6] Front Right [7] - /// Front Left - /// - FrcFlcFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Empty [4] Empty [5] Low Frequency Effects [6] - /// Front Right [7] Front Left - /// - FrcFlcLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Empty [4] Front Center [5] Empty [6] Front Right - /// [7] Front Left - /// - FrcFlcFcFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Empty [4] Front Center [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - FrcFlcFcLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Rear Center [4] Empty [5] Empty [6] Front Right - /// [7] Front Left - /// - FrcFlcRcFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Rear Center [4] Empty [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - FrcFlcRcLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Rear Center [4] Front Center [5] Empty [6] Front - /// Right [7] Front Left - /// - FrcFlcRcFcFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Empty [3] Rear Center [4] Front Center [5] Low Frequency - /// Effects [6] Front Right [7] Front Left - /// - FrcFlcRcFcLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right - /// [7] Front Left - /// - FrcFlcRrRlFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - FrcFlcRrRlLfeFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] - /// Front Right [7] Front Left - /// - FrcFlcRrRlFcFrFl, - - /// - /// [0] Front Right Of Center [1] Front Left Of Center [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency - /// Effects [6] Front Right [7] Front Left - /// - FrcFlcRrRlFcLfeFrFl, - - /// - /// [0] Empty [1] Front Center High [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] Front - /// Left - /// - FchRrRlFcFrFl, - - /// - /// [0] Empty [1] Front Center High [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] Front - /// Right [7] Front Left - /// - FchRrRlFcLfeFrFl, - - /// - /// [0] TopCenter [1] Empty [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] Front Left - /// - TcRrRlFcFrFl, - - /// - /// [0] TopCenter [1] Empty [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] Front Right [7] - /// Front Left - /// - TcRrRlFcLfeFrFl, - - /// - /// [0] Front Right High [1] Front Left High [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right [7] Front - /// Left - /// - FrhFlhRrRlFrFl, - - /// - /// [0] Front Right High [1] Front Left High [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects [6] Front - /// Right [7] Front Left - /// - FrhFlhRrRlLfeFrFl, - - /// - /// [0] Front Right Wide [1] Front Left Wide [2] Rear Right [3] Rear Left [4] Empty [5] Empty [6] Front Right [7] Front - /// Left - /// - FrwFlwRrRlFrFl, - - /// - /// [0] Front Right Wide [1] Front Left Wide [2] Rear Right [3] Rear Left [4] Empty [5] Low Frequency Effects [6] Front - /// Right [7] Front Left - /// - FrwFlwRrRlLfeFrFl, - - /// - /// [0] TopCenter [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] Front - /// Left - /// - TcRcRrRlFcFrFl, - - /// - /// [0] TopCenter [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] Front - /// Right [7] Front Left - /// - TcRcRrRlFcLfeFrFl, - - /// - /// [0] Front Center High [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] - /// Front Left - /// - FchRcRrRlFcFrFl, - - /// - /// [0] Front Center High [1] Rear Center [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] - /// Front Right [7] Front Left - /// - FchRcRrRlFcLfeFrFl, - - /// - /// [0] TopCenter [1] Front Center High [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right [7] - /// Front Left - /// - TcFcRrRlFcFrFl, - - /// - /// [0] TopCenter [1] Front Center High [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects [6] - /// Front Right [7] Front Left - /// - TcFchRrRlFcLfeFrFl, - - /// - /// [0] Front Right High [1] Front Left High [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right - /// [7] Front Left - /// - FrhFlhRrRlFcFrFl, - - /// - /// [0] Front Right High [1] Front Left High [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - FrhFlhRrRlFcLfeFrFl, - - /// - /// [0] Front Right Wide [1] Front Left Wide [2] Rear Right [3] Rear Left [4] Front Center [5] Empty [6] Front Right - /// [7] Front Left - /// - FrwFlwRrRlFcFeFl, - - /// - /// [0] Front Right Wide [1] Front Left Wide [2] Rear Right [3] Rear Left [4] Front Center [5] Low Frequency Effects - /// [6] Front Right [7] Front Left - /// - FrwFlwRrRlFcLfeFrFl, - - /// - /// Auto (Unspecified) - /// - Auto = 511 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelCount.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelCount.cs deleted file mode 100644 index 71e76c8f..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioChannelCount.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio channels - /// - public enum InfoFrameAudioChannelCount : uint - { - /// - /// Data is available in the header of source data - /// - InHeader = 0, - - /// - /// Two channels - /// - Two, - - /// - /// Three channels - /// - Three, - - /// - /// Four channels - /// - Four, - - /// - /// Five channels - /// - Five, - - /// - /// Six channels - /// - Six, - - /// - /// Seven channels - /// - Seven, - - /// - /// Eight channels - /// - Eight, - - /// - /// Auto (Unspecified) - /// - Auto = 15 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioCodec.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioCodec.cs deleted file mode 100644 index 0db6fcf1..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioCodec.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio codecs - /// - public enum InfoFrameAudioCodec : uint - { - /// - /// Data is available in the header of source data - /// - InHeader = 0, - - /// - /// Pulse-code modulation - /// - PCM, - - /// - /// Dolby AC-3 - /// - AC3, - - /// - /// MPEG1 - /// - MPEG1, - - /// - /// MP3 (MPEG-2 Audio Layer III) - /// - MP3, - - /// - /// MPEG2 - /// - MPEG2, - - /// - /// Advanced Audio Coding - /// - AACLC, - - /// - /// DTS - /// - DTS, - - /// - /// Adaptive Transform Acoustic Coding - /// - ATRAC, - - /// - /// Direct Stream Digital - /// - DSD, - - /// - /// Dolby Digital Plus - /// - EAC3, - - /// - /// DTS High Definition - /// - DTSHD, - - /// - /// Meridian Lossless Packing - /// - MLP, - - /// - /// DST - /// - DST, - - /// - /// Windows Media Audio Pro - /// - WMAPRO, - - /// - /// Extended audio codec value should be used to get information regarding audio codec - /// - UseExtendedCodecType, - - /// - /// Auto (Unspecified) - /// - Auto = 31 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioExtendedCodec.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioExtendedCodec.cs deleted file mode 100644 index 82dfdde7..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioExtendedCodec.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible extended audio codecs - /// - public enum InfoFrameAudioExtendedCodec : uint - { - /// - /// Use the primary audio codec type, data not available - /// - UseCodecType = 0, - - /// - /// High-Efficiency Advanced Audio Coding - /// - HEAAC, - - /// - /// High-Efficiency Advanced Audio Coding 2 - /// - HEAACVersion2, - - /// - /// MPEG Surround - /// - MPEGSurround, - - /// - /// Auto (Unspecified) - /// - Auto = 63 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioLFEPlaybackLevel.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioLFEPlaybackLevel.cs deleted file mode 100644 index 7988db35..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioLFEPlaybackLevel.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio low frequency effects channel playback level - /// - public enum InfoFrameAudioLFEPlaybackLevel : uint - { - /// - /// Data not available - /// - NoData = 0, - - /// - /// No change to the source audio - /// - Plus0Decibel, - - /// - /// Adds 10 decibel - /// - Plus10Decibel, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioLevelShift.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioLevelShift.cs deleted file mode 100644 index 64e3b21f..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioLevelShift.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio channel level shift values - /// - public enum InfoFrameAudioLevelShift : uint - { - /// - /// No change to the source audio - /// - Shift0Decibel = 0, - - /// - /// Shifts 1 decibel - /// - Shift1Decibel, - - /// - /// Shifts 2 decibel - /// - Shift2Decibel, - - /// - /// Shifts 3 decibel - /// - Shift3Decibel, - - /// - /// Shifts 4 decibel - /// - Shift4Decibel, - - /// - /// Shifts 5 decibel - /// - Shift5Decibel, - - /// - /// Shifts 6 decibel - /// - Shift6Decibel, - - /// - /// Shifts 7 decibel - /// - Shift7Decibel, - - /// - /// Shifts 8 decibel - /// - Shift8Decibel, - - /// - /// Shifts 9 decibel - /// - Shift9Decibel, - - /// - /// Shifts 10 decibel - /// - Shift10Decibel, - - /// - /// Shifts 11 decibel - /// - Shift11Decibel, - - /// - /// Shifts 12 decibel - /// - Shift12Decibel, - - /// - /// Shifts 13 decibel - /// - Shift13Decibel, - - /// - /// Shifts 14 decibel - /// - Shift14Decibel, - - /// - /// Shifts 15 decibel - /// - Shift15Decibel, - - /// - /// Auto (Unspecified) - /// - Auto = 31 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleRate.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleRate.cs deleted file mode 100644 index f283e1c9..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleRate.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio sample rates (sampling frequency) - /// - public enum InfoFrameAudioSampleRate : uint - { - /// - /// Data is available in the header of source data - /// - InHeader = 0, - - /// - /// 31kHz sampling frequency - /// - F32000Hz, - - /// - /// 44.1kHz sampling frequency - /// - F44100Hz, - - /// - /// 48kHz sampling frequency - /// - F48000Hz, - - /// - /// 88.2kHz sampling frequency - /// - F88200Hz, - - /// - /// 96kHz sampling frequency - /// - F96000Hz, - - /// - /// 176.4kHz sampling frequency - /// - F176400Hz, - - /// - /// 192kHz sampling frequency - /// - F192000Hz, - - /// - /// Auto (Unspecified) - /// - Auto = 15 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleSize.cs b/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleSize.cs deleted file mode 100644 index 361279cc..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameAudioSampleSize.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible audio sample size (bit depth) - /// - public enum InfoFrameAudioSampleSize : uint - { - /// - /// Data is available in the header of source data - /// - InHeader = 0, - - /// - /// 16bit audio sample size - /// - B16, - - /// - /// 20bit audio sample size - /// - B20, - - /// - /// 24bit audio sample size - /// - B24, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameBoolean.cs b/app/NvAPIWrapper/Native/Display/InfoFrameBoolean.cs deleted file mode 100644 index 0aa0e45c..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameBoolean.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for info-frame properties that accept or return a boolean value - /// - public enum InfoFrameBoolean : uint - { - /// - /// False - /// - False = 0, - - /// - /// True - /// - True, - - /// - /// Auto (Unspecified) - /// - Auto = 3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameCommand.cs b/app/NvAPIWrapper/Native/Display/InfoFrameCommand.cs deleted file mode 100644 index 578bb59a..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameCommand.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible commands for info-frame operations - /// - public enum InfoFrameCommand : uint - { - /// - /// Returns the fields in the info-frame with values set by the manufacturer (NVIDIA or OEM) - /// - GetDefault = 0, - - /// - /// Sets the fields in the info-frame to auto, and info-frame to the default info-frame for use in a set. - /// - Reset, - - /// - /// Get the current info-frame state. - /// - Get, - - /// - /// Set the current info-frame state (flushed to the monitor), the values are one time and do not persist. - /// - Set, - - /// - /// Get the override info-frame state, non-override fields will be set to value = AUTO, overridden fields will have the - /// current override values. - /// - GetOverride, - - /// - /// Set the override info-frame state, non-override fields will be set to value = AUTO, other values indicate override; - /// persist across mode-set and reboot. - /// - SetOverride, - - /// - /// Get properties associated with info-frame (each of the info-frame type will have properties). - /// - GetProperty, - - /// - /// Set properties associated with info-frame. - /// - SetProperty - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameDataType.cs b/app/NvAPIWrapper/Native/Display/InfoFrameDataType.cs deleted file mode 100644 index 50db98ff..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameDataType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible info-frame data type - /// - public enum InfoFrameDataType : uint - { - /// - /// Auxiliary Video data - /// - AuxiliaryVideoInformation = 2, - - /// - /// Audio data - /// - AudioInformation = 4, - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFramePropertyMode.cs b/app/NvAPIWrapper/Native/Display/InfoFramePropertyMode.cs deleted file mode 100644 index 93ac83bc..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFramePropertyMode.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible info-frame property modes - /// - public enum InfoFramePropertyMode : uint - { - /// - /// Driver determines whether to send info-frames. - /// - Auto = 0, - - /// - /// Driver always sends info-frame. - /// - Enable, - - /// - /// Driver never sends info-frame. - /// - Disable, - - /// - /// Driver only sends info-frame when client requests it via info-frame escape call. - /// - AllowOverride - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioActivePortion.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioActivePortion.cs deleted file mode 100644 index 5c0ffe7e..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioActivePortion.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for AVI aspect ratio portions - /// - public enum InfoFrameVideoAspectRatioActivePortion : uint - { - /// - /// Disabled or not available - /// - Disabled = 0, - - /// - /// Letter box 16x9 - /// - LetterboxGreaterThan16X9 = 4, - - /// - /// Equal to the source frame size - /// - EqualCodedFrame = 8, - - /// - /// Centered 4x3 ratio - /// - Center4X3 = 9, - - /// - /// Centered 16x9 ratio - /// - Center16X9 = 10, - - /// - /// Centered 14x9 ratio - /// - Center14X9 = 11, - - /// - /// Bordered 4x3 on 14x9 - /// - Bordered4X3On14X9 = 13, - - /// - /// Bordered 16x9 on 14x9 - /// - Bordered16X9On14X9 = 14, - - /// - /// Bordered 16x9 on 4x3 - /// - Bordered16X9On4X3 = 15, - - /// - /// Auto (Unspecified) - /// - Auto = 31 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioCodedFrame.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioCodedFrame.cs deleted file mode 100644 index 246853de..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoAspectRatioCodedFrame.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Gets the possible values for AVI source aspect ratio - /// - public enum InfoFrameVideoAspectRatioCodedFrame : uint - { - /// - /// No data available - /// - NoData = 0, - - /// - /// The 4x3 aspect ratio - /// - Aspect4X3, - - /// - /// The 16x9 aspect ratio - /// - Aspect16X9, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoBarData.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoBarData.cs deleted file mode 100644 index 16f3e09f..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoBarData.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI bar data that are available and should be used - /// - public enum InfoFrameVideoBarData : uint - { - /// - /// No bar data present - /// - NotPresent = 0, - - /// - /// Vertical bar - /// - Vertical, - - /// - /// Horizontal bar - /// - Horizontal, - - /// - /// Both sides have bars - /// - Both, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorFormat.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorFormat.cs deleted file mode 100644 index b3c2faec..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorFormat.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI color formats - /// - public enum InfoFrameVideoColorFormat : uint - { - /// - /// The RGB color format - /// - RGB = 0, - - /// - /// The YCbCr422 color format - /// - YCbCr422, - - /// - /// The YCbCr444 color format - /// - YCbCr444, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorimetry.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorimetry.cs deleted file mode 100644 index 9beccb9f..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoColorimetry.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the AVI color space - /// - public enum InfoFrameVideoColorimetry : uint - { - /// - /// No data available - /// - NoData = 0, - - /// - /// The SMPTE170M color space - /// - SMPTE170M, - - /// - /// The ITURBT709 color space - /// - ITURBT709, - - /// - /// Extended colorimetry value should be used to get information regarding AVI color space - /// - UseExtendedColorimetry, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoContentType.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoContentType.cs deleted file mode 100644 index 2d511554..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoContentType.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI content type - /// - public enum InfoFrameVideoContentType : uint - { - /// - /// Graphics content - /// - Graphics = 0, - - /// - /// Photo content - /// - Photo, - - /// - /// Cinematic content - /// - Cinema, - - /// - /// Gaming content - /// - Game, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoExtendedColorimetry.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoExtendedColorimetry.cs deleted file mode 100644 index dbb374af..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoExtendedColorimetry.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the AVI extended color space - /// - public enum InfoFrameVideoExtendedColorimetry : uint - { - /// - /// The xvYCC601 color space - /// - // ReSharper disable once InconsistentNaming - xvYCC601 = 0, - - /// - /// The xvYCC709 color space - /// - // ReSharper disable once InconsistentNaming - xvYCC709, - - /// - /// The sYCC601 color space - /// - // ReSharper disable once InconsistentNaming - sYCC601, - - /// - /// The AdobeYCC601 color space - /// - AdobeYCC601, - - /// - /// The AdobeRGB color space - /// - AdobeRGB, - - /// - /// Auto (Unspecified) - /// - Auto = 15 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoITC.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoITC.cs deleted file mode 100644 index ca2cba40..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoITC.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI video content modes - /// - public enum InfoFrameVideoITC : uint - { - /// - /// Normal video content (Consumer Electronics) - /// - VideoContent = 0, - - /// - /// Information Technology content - /// - ITContent, - - /// - /// Auto (Unspecified) - /// - Auto = 3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoNonUniformPictureScaling.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoNonUniformPictureScaling.cs deleted file mode 100644 index 63a95c83..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoNonUniformPictureScaling.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the AVI non uniform picture scaling - /// - public enum InfoFrameVideoNonUniformPictureScaling : uint - { - /// - /// No data available - /// - NoData = 0, - - /// - /// Horizontal scaling - /// - Horizontal, - - /// - /// Vertical scaling - /// - Vertical, - - /// - /// Scaling in both directions - /// - Both, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoPixelRepetition.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoPixelRepetition.cs deleted file mode 100644 index bb725d63..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoPixelRepetition.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI pixel repetition values - /// - public enum InfoFrameVideoPixelRepetition : uint - { - /// - /// No pixel repetition - /// - None = 0, - - /// - /// Two pixel repetition - /// - X2, - - /// - /// Three pixel repetition - /// - X3, - - /// - /// Four pixel repetition - /// - X4, - - /// - /// Five pixel repetition - /// - X5, - - /// - /// Six pixel repetition - /// - X6, - - /// - /// Seven pixel repetition - /// - X7, - - /// - /// Eight pixel repetition - /// - X8, - - /// - /// Nine pixel repetition - /// - X9, - - /// - /// Ten pixel repetition - /// - X10, - - /// - /// Auto (Unspecified) - /// - Auto = 31 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoRGBQuantization.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoRGBQuantization.cs deleted file mode 100644 index 64b613fd..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoRGBQuantization.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the AVI RGB quantization - /// - public enum InfoFrameVideoRGBQuantization : uint - { - /// - /// Default setting - /// - Default = 0, - - /// - /// Limited RGB range [16-235] (86%) - /// - LimitedRange, - - /// - /// Full RGB range [0-255] (100%) - /// - FullRange, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoScanInfo.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoScanInfo.cs deleted file mode 100644 index fbed2f32..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoScanInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for AVI scan information - /// - public enum InfoFrameVideoScanInfo : uint - { - /// - /// No data available - /// - NoData = 0, - - /// - /// Overscan - /// - OverScan, - - /// - /// Underscan - /// - UnderScan, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/InfoFrameVideoYCCQuantization.cs b/app/NvAPIWrapper/Native/Display/InfoFrameVideoYCCQuantization.cs deleted file mode 100644 index 5b8238ba..00000000 --- a/app/NvAPIWrapper/Native/Display/InfoFrameVideoYCCQuantization.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible AVI YCC quantization - /// - public enum InfoFrameVideoYCCQuantization : uint - { - /// - /// Limited YCC range - /// - LimitedRange = 0, - - /// - /// Full YCC range - /// - FullRange, - - /// - /// Auto (Unspecified) - /// - Auto = 7 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesConnectorType.cs b/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesConnectorType.cs deleted file mode 100644 index 15c45d70..00000000 --- a/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesConnectorType.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible values for the monitor capabilities connector type - /// - public enum MonitorCapabilitiesConnectorType : uint - { - /// - /// Unknown or invalid connector - /// - Unknown = 0, - - /// - /// VGA connector - /// - VGA, - - /// - /// Composite connector (TV) - /// - TV, - - /// - /// DVI connector - /// - DVI, - - /// - /// HDMI connector - /// - HDMI, - - /// - /// Display Port connector - /// - DisplayPort - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesType.cs b/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesType.cs deleted file mode 100644 index 0b6958dd..00000000 --- a/app/NvAPIWrapper/Native/Display/MonitorCapabilitiesType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the monitor capabilities type - /// - public enum MonitorCapabilitiesType : uint - { - /// - /// The Vendor Specific Data Block - /// - VSDB = 0x1000, - - /// - /// The Video Capability Data Block - /// - VCDB = 0x1001 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Rotate.cs b/app/NvAPIWrapper/Native/Display/Rotate.cs deleted file mode 100644 index 171d4d34..00000000 --- a/app/NvAPIWrapper/Native/Display/Rotate.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible rotate modes - /// - public enum Rotate : uint - { - /// - /// No rotation - /// - Degree0 = 0, - - /// - /// 90 degree rotation - /// - Degree90 = 1, - - /// - /// 180 degree rotation - /// - Degree180 = 2, - - /// - /// 270 degree rotation - /// - Degree270 = 3, - - /// - /// This value is ignored - /// - Ignored = 4 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Scaling.cs b/app/NvAPIWrapper/Native/Display/Scaling.cs deleted file mode 100644 index 7c4e15d7..00000000 --- a/app/NvAPIWrapper/Native/Display/Scaling.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible scaling modes - /// - public enum Scaling - { - /// - /// No change - /// - Default = 0, - - /// - /// Balanced - Full Screen - /// - ToClosest = 1, - - /// - /// Force GPU - Full Screen - /// - ToNative = 2, - - /// - /// Force GPU - Centered\No Scaling - /// - GPUScanOutToNative = 3, - - /// - /// Force GPU - Aspect Ratio - /// - ToAspectScanOutToNative = 5, - - /// - /// Balanced - Aspect Ratio - /// - ToAspectScanOutToClosest = 6, - - /// - /// Balanced - Centered\No Scaling - /// - GPUScanOutToClosest = 7, - - /// - /// Customized scaling - For future use - /// - Customized = 255 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameter.cs b/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameter.cs deleted file mode 100644 index 4d762560..00000000 --- a/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameter.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Holds a list of possible scan out composition configurable parameters - /// - public enum ScanOutCompositionParameter : uint - { - /// - /// Warping re-sampling method parameter - /// - WarpingReSamplingMethod = 0 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameterValue.cs b/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameterValue.cs deleted file mode 100644 index e1ae3286..00000000 --- a/app/NvAPIWrapper/Native/Display/ScanOutCompositionParameterValue.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Holds a list of possible scan out composition parameter values - /// - public enum ScanOutCompositionParameterValue : uint - { - /// - /// Default parameter value - /// - Default = 0, - - /// - /// BiLinear value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBiLinear = 0x100, - - /// - /// Bicubic Triangular value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicTriangular = 0x101, - - /// - /// Bicubic Bell Shaped value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicBellShaped = 0x102, - - /// - /// Bicubic B-Spline value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicBSpline = 0x103, - - /// - /// Bicubic Adaptive Triangular value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicAdaptiveTriangular = 0x104, - - /// - /// Bicubic Adaptive Bell Shaped value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicAdaptiveBellShaped = 0x105, - - /// - /// Bicubic Adaptive B-Spline value for the warping re-sampling method parameter - /// - WarpingReSamplingMethodBicubicAdaptiveBSpline = 0x106 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/SpanningOrientation.cs b/app/NvAPIWrapper/Native/Display/SpanningOrientation.cs deleted file mode 100644 index ee4b265b..00000000 --- a/app/NvAPIWrapper/Native/Display/SpanningOrientation.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Display spanning for Windows XP - /// - public enum SpanningOrientation - { - /// - /// No spanning - /// - None = 0, - - /// - /// Horizontal spanning - /// - Horizontal = 1, - - /// - /// Vertical spanning - /// - Vertical = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/StaticMetadataDescriptorId.cs b/app/NvAPIWrapper/Native/Display/StaticMetadataDescriptorId.cs deleted file mode 100644 index 4a02f72d..00000000 --- a/app/NvAPIWrapper/Native/Display/StaticMetadataDescriptorId.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Contains possible values for the type of the Static Metadata Descriptor block structure - /// - public enum StaticMetadataDescriptorId : uint - { - /// - /// Type 1 Static Metadata Descriptor block structure - /// - StaticMetadataType1 = 0 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataColorCoordinate.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataColorCoordinate.cs deleted file mode 100644 index 40cef00a..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataColorCoordinate.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds coordinates of a color in the color space - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ColorDataColorCoordinate : IEquatable - { - private readonly ushort _X; - private readonly ushort _Y; - - /// - /// Gets the color space's X coordinate - /// - public float X - { - get => (float) _X / 0xC350; - } - - /// - /// Gets the color space's Y coordinate - /// - public float Y - { - get => (float) _Y / 0xC350; - } - - /// - /// Creates an instance of . - /// - /// The color space's X coordinate. - /// The color space's Y coordinate. - public ColorDataColorCoordinate(float x, float y) - { - _X = (ushort) (Math.Min(Math.Max(x, 0), 1) * 0xC350); - _Y = (ushort) (Math.Min(Math.Max(y, 0), 1) * 0xC350); - } - - /// - /// Creates an instance of . - /// - /// The color space's coordinates. - public ColorDataColorCoordinate(PointF coordinate) : this(coordinate.X, coordinate.Y) - { - } - - /// - public override string ToString() - { - return $"({X:F3}, {Y:F3})"; - } - - /// - public bool Equals(ColorDataColorCoordinate other) - { - return _X == other._X && _Y == other._Y; - } - - /// - public override bool Equals(object obj) - { - return obj is ColorDataColorCoordinate other && Equals(other); - } - - /// - public override int GetHashCode() - { - unchecked - { - return (_X.GetHashCode() * 397) ^ _Y.GetHashCode(); - } - } - - /// - /// Checks two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// true if both instances are equal, otherwise false. - public static bool operator ==(ColorDataColorCoordinate left, ColorDataColorCoordinate right) - { - return left.Equals(right); - } - - /// - /// Checks two instance of for inequality. - /// - /// The first instance. - /// The second instance. - /// true if both instances are not equal, otherwise false. - public static bool operator !=(ColorDataColorCoordinate left, ColorDataColorCoordinate right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataV1.cs deleted file mode 100644 index f2c6eef2..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV1.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ColorDataV1 : IInitializable, IColorData - { - internal StructureVersion _Version; - internal ushort _Size; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - private readonly ColorDataBag _Data; - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - private struct ColorDataBag - { - public readonly byte ColorFormat; - public readonly byte Colorimetry; - - public ColorDataBag(ColorDataFormat colorFormat, ColorDataColorimetry colorimetry) - { - ColorFormat = (byte)colorFormat; - Colorimetry = (byte)colorimetry; - } - } - - /// - /// Creates an instance of to retrieve color data information - /// - /// The command to be executed. - public ColorDataV1(ColorDataCommand command) - { - this = typeof(ColorDataV1).Instantiate(); - _Size = (ushort)_Version.StructureSize; - - if (command != ColorDataCommand.Get && command != ColorDataCommand.GetDefault) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte)command; - } - - /// - /// Creates an instance of to modify the color data - /// - /// The command to be executed. - /// The color data color format. - /// The color data color space. - public ColorDataV1( - ColorDataCommand command, - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry - ) - { - this = typeof(ColorDataV1).Instantiate(); - _Size = (ushort)_Version.StructureSize; - - if (command != ColorDataCommand.Set && command != ColorDataCommand.IsSupportedColor) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte)command; - _Data = new ColorDataBag(colorFormat, colorimetry); - } - - /// - public ColorDataFormat ColorFormat - { - get => (ColorDataFormat)_Data.ColorFormat; - } - - /// - public ColorDataColorimetry Colorimetry - { - get => (ColorDataColorimetry)_Data.Colorimetry; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => null; - } - - /// - public ColorDataDepth? ColorDepth - { - get => null; - } - - /// - public ColorDataSelectionPolicy? SelectionPolicy - { - get => null; - } - - /// - public ColorDataDesktopDepth? DesktopColorDepth - { - get => null; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV2.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataV2.cs deleted file mode 100644 index 4a8c7cb1..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV2.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct ColorDataV2 : IInitializable, IColorData - { - internal StructureVersion _Version; - internal ushort _Size; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - private readonly ColorDataBag _Data; - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - private struct ColorDataBag - { - public readonly byte ColorFormat; - public readonly byte Colorimetry; - public readonly byte ColorDynamicRange; - - public ColorDataBag( - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange - ) - { - ColorFormat = (byte) colorFormat; - Colorimetry = (byte) colorimetry; - ColorDynamicRange = (byte) colorDynamicRange; - } - } - - /// - /// Creates an instance of to retrieve color data information - /// - /// The command to be executed. - public ColorDataV2(ColorDataCommand command) - { - this = typeof(ColorDataV2).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Get && command != ColorDataCommand.GetDefault) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - } - - /// - /// Creates an instance of to modify the color data - /// - /// The command to be executed. - /// The color data color format. - /// The color data color space. - /// The color data dynamic range. - public ColorDataV2( - ColorDataCommand command, - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange - ) - { - this = typeof(ColorDataV2).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Set && command != ColorDataCommand.IsSupportedColor) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Data = new ColorDataBag(colorFormat, colorimetry, colorDynamicRange); - } - - /// - public ColorDataFormat ColorFormat - { - get => (ColorDataFormat) _Data.ColorFormat; - } - - /// - public ColorDataColorimetry Colorimetry - { - get => (ColorDataColorimetry) _Data.Colorimetry; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => (ColorDataDynamicRange) _Data.ColorDynamicRange; - } - - /// - public ColorDataDepth? ColorDepth - { - get => null; - } - - /// - public ColorDataSelectionPolicy? SelectionPolicy - { - get => null; - } - - /// - public ColorDataDesktopDepth? DesktopColorDepth - { - get => null; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV3.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataV3.cs deleted file mode 100644 index 9757c07b..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV3.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct ColorDataV3 : IInitializable, IColorData - { - internal StructureVersion _Version; - internal ushort _Size; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - private readonly ColorDataBag _Data; - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - private struct ColorDataBag - { - public readonly byte ColorFormat; - public readonly byte Colorimetry; - public readonly byte ColorDynamicRange; - public readonly ColorDataDepth ColorDepth; - - public ColorDataBag( - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange, - ColorDataDepth colorDepth - ) - { - ColorFormat = (byte) colorFormat; - Colorimetry = (byte) colorimetry; - ColorDynamicRange = (byte) colorDynamicRange; - ColorDepth = colorDepth; - } - } - - /// - /// Creates an instance of to retrieve color data information - /// - /// The command to be executed. - public ColorDataV3(ColorDataCommand command) - { - this = typeof(ColorDataV3).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Get && command != ColorDataCommand.GetDefault) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - } - - /// - /// Creates an instance of to modify the color data - /// - /// The command to be executed. - /// The color data color format. - /// The color data color space. - /// The color data dynamic range. - /// The color data color depth. - public ColorDataV3( - ColorDataCommand command, - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange, - ColorDataDepth colorDepth - ) - { - this = typeof(ColorDataV3).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Set && command != ColorDataCommand.IsSupportedColor) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Data = new ColorDataBag(colorFormat, colorimetry, colorDynamicRange, colorDepth); - } - - /// - public ColorDataFormat ColorFormat - { - get => (ColorDataFormat) _Data.ColorFormat; - } - - /// - public ColorDataColorimetry Colorimetry - { - get => (ColorDataColorimetry) _Data.Colorimetry; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => (ColorDataDynamicRange) _Data.ColorDynamicRange; - } - - /// - public ColorDataDepth? ColorDepth - { - get - { - switch ((int) _Data.ColorDepth) - { - case 6: - return ColorDataDepth.BPC6; - case 8: - return ColorDataDepth.BPC8; - case 10: - return ColorDataDepth.BPC10; - case 12: - return ColorDataDepth.BPC12; - case 16: - return ColorDataDepth.BPC16; - default: - return _Data.ColorDepth; - } - } - } - - /// - public ColorDataSelectionPolicy? SelectionPolicy - { - get => null; - } - - /// - public ColorDataDesktopDepth? DesktopColorDepth - { - get => null; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV4.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataV4.cs deleted file mode 100644 index c7a8a0e4..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV4.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(4)] - public struct ColorDataV4 : IInitializable, IColorData - { - internal StructureVersion _Version; - internal ushort _Size; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - private readonly ColorDataBag _Data; - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - private struct ColorDataBag - { - public readonly byte ColorFormat; - public readonly byte Colorimetry; - public readonly byte ColorDynamicRange; - public readonly ColorDataDepth ColorDepth; - public readonly ColorDataSelectionPolicy ColorSelectionPolicy; - - public ColorDataBag( - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange, - ColorDataDepth colorDepth, - ColorDataSelectionPolicy colorSelectionPolicy - ) - { - ColorFormat = (byte) colorFormat; - Colorimetry = (byte) colorimetry; - ColorDynamicRange = (byte) colorDynamicRange; - ColorDepth = colorDepth; - ColorSelectionPolicy = colorSelectionPolicy; - } - } - - /// - /// Creates an instance of to retrieve color data information - /// - /// The command to be executed. - public ColorDataV4(ColorDataCommand command) - { - this = typeof(ColorDataV4).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Get && command != ColorDataCommand.GetDefault) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - } - - /// - /// Creates an instance of to modify the color data - /// - /// The command to be executed. - /// The color data color format. - /// The color data color space. - /// The color data dynamic range. - /// The color data color depth. - /// The color data selection policy. - public ColorDataV4( - ColorDataCommand command, - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange, - ColorDataDepth colorDepth, - ColorDataSelectionPolicy colorSelectionPolicy - ) - { - this = typeof(ColorDataV4).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Set && command != ColorDataCommand.IsSupportedColor) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Data = new ColorDataBag(colorFormat, colorimetry, colorDynamicRange, colorDepth, colorSelectionPolicy); - } - - /// - public ColorDataFormat ColorFormat - { - get => (ColorDataFormat) _Data.ColorFormat; - } - - /// - public ColorDataColorimetry Colorimetry - { - get => (ColorDataColorimetry) _Data.Colorimetry; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => (ColorDataDynamicRange) _Data.ColorDynamicRange; - } - - /// - public ColorDataDepth? ColorDepth - { - get - { - switch ((int) _Data.ColorDepth) - { - case 6: - return ColorDataDepth.BPC6; - case 8: - return ColorDataDepth.BPC8; - case 10: - return ColorDataDepth.BPC10; - case 12: - return ColorDataDepth.BPC12; - case 16: - return ColorDataDepth.BPC16; - default: - return _Data.ColorDepth; - } - } - } - - /// - public ColorDataSelectionPolicy? SelectionPolicy - { - get => _Data.ColorSelectionPolicy; - } - - /// - public ColorDataDesktopDepth? DesktopColorDepth - { - get => null; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV5.cs b/app/NvAPIWrapper/Native/Display/Structures/ColorDataV5.cs deleted file mode 100644 index 919a44e0..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ColorDataV5.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(5)] - public struct ColorDataV5 : IInitializable, IColorData - { - internal StructureVersion _Version; - internal ushort _Size; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - private readonly ColorDataBag _Data; - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - private struct ColorDataBag - { - public readonly byte ColorFormat; - public readonly byte Colorimetry; - public readonly byte ColorDynamicRange; - public readonly ColorDataDepth ColorDepth; - public readonly ColorDataSelectionPolicy ColorSelectionPolicy; - public readonly ColorDataDesktopDepth DesktopColorDepth; - - public ColorDataBag( - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange colorDynamicRange, - ColorDataDepth colorDepth, - ColorDataSelectionPolicy colorSelectionPolicy, - ColorDataDesktopDepth desktopColorDepth - ) - { - ColorFormat = (byte) colorFormat; - Colorimetry = (byte) colorimetry; - ColorDynamicRange = (byte) colorDynamicRange; - ColorDepth = colorDepth; - ColorSelectionPolicy = colorSelectionPolicy; - DesktopColorDepth = desktopColorDepth; - } - } - - /// - /// Creates an instance of to retrieve color data information - /// - /// The command to be executed. - public ColorDataV5(ColorDataCommand command) - { - this = typeof(ColorDataV5).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Get && command != ColorDataCommand.GetDefault) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - } - - /// - /// Creates an instance of to modify the color data - /// - /// The command to be executed. - /// The color data color format. - /// The color data color space. - /// The color data dynamic range. - /// The color data color depth. - /// The color data selection policy. - /// The color data desktop color depth. - public ColorDataV5( - ColorDataCommand command, - ColorDataFormat colorFormat, - ColorDataColorimetry colorimetry, - ColorDataDynamicRange dynamicRange, - ColorDataDepth colorDepth, - ColorDataSelectionPolicy colorSelectionPolicy, - ColorDataDesktopDepth desktopColorDepth - ) - { - this = typeof(ColorDataV5).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != ColorDataCommand.Set && command != ColorDataCommand.IsSupportedColor) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Data = new ColorDataBag( - colorFormat, - colorimetry, - dynamicRange, - colorDepth, - colorSelectionPolicy, - desktopColorDepth - ); - } - - /// - public ColorDataFormat ColorFormat - { - get => (ColorDataFormat) _Data.ColorFormat; - } - - /// - public ColorDataColorimetry Colorimetry - { - get => (ColorDataColorimetry) _Data.Colorimetry; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => (ColorDataDynamicRange) _Data.ColorDynamicRange; - } - - /// - public ColorDataDepth? ColorDepth - { - get - { - switch ((int) _Data.ColorDepth) - { - case 6: - return ColorDataDepth.BPC6; - case 8: - return ColorDataDepth.BPC8; - case 10: - return ColorDataDepth.BPC10; - case 12: - return ColorDataDepth.BPC12; - case 16: - return ColorDataDepth.BPC16; - default: - return _Data.ColorDepth; - } - } - } - - /// - public ColorDataSelectionPolicy? SelectionPolicy - { - get => _Data.ColorSelectionPolicy; - } - - /// - public ColorDataDesktopDepth? DesktopColorDepth - { - get => _Data.DesktopColorDepth; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/CustomDisplay.cs b/app/NvAPIWrapper/Native/Display/Structures/CustomDisplay.cs deleted file mode 100644 index a668934c..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/CustomDisplay.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Hold information about a custom display resolution - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct CustomDisplay : IInitializable - { - internal StructureVersion _Version; - internal uint _Width; - internal uint _Height; - internal uint _Depth; - internal ColorFormat _ColorFormat; - internal ViewPortF _SourcePartition; - internal float _XRatio; - internal float _YRatio; - internal Timing _Timing; - internal uint _Flags; - - /// - /// Gets the source surface (source mode) width. - /// - public uint Width - { - get => _Width; - } - - /// - /// Gets the source surface (source mode) height. - /// - public uint Height - { - get => _Height; - } - - /// - /// Gets the source surface color depth. "0" means all 8/16/32bpp. - /// - public uint Depth - { - get => _Depth; - } - - /// - /// Gets the color format (optional) - /// - public ColorFormat ColorFormat - { - get => _ColorFormat; - } - - /// - /// Gets the source partition viewport. All values are between [0, 1]. For multi-mon support, should be set to - /// (0,0,1.0,1.0) for now. - /// - public ViewPortF SourcePartition - { - get => _SourcePartition; - } - - /// - /// Gets the horizontal scaling ratio. - /// - public float XRatio - { - get => _XRatio; - } - - /// - /// Gets the vertical scaling ratio. - /// - public float YRatio - { - get => _YRatio; - } - - /// - /// Gets the timing used to program TMDS/DAC/LVDS/HDMI/TVEncoder, etc. - /// - public Timing Timing - { - get => _Timing; - } - - /// - /// Gets a boolean value indicating that a hardware mode-set without OS update should be performed. - /// - public bool HardwareModeSetOnly - { - get => _Flags.GetBit(0); - } - - /// - /// Creates an instance of - /// - /// The source surface (source mode) width. - /// The source surface (source mode) height. - /// The source surface color depth. "0" means all 8/16/32bpp. - /// The color format (optional) - /// The horizontal scaling ratio. - /// The vertical scaling ratio. - /// The timing used to program TMDS/DAC/LVDS/HDMI/TVEncoder, etc. - /// A boolean value indicating that a hardware mode-set without OS update should be performed. - public CustomDisplay( - uint width, - uint height, - uint depth, - ColorFormat colorFormat, - float xRatio, - float yRatio, - Timing timing, - bool hwModeSetOnly - ) - { - this = typeof(CustomDisplay).Instantiate(); - - _Width = width; - _Height = height; - _Depth = depth; - _ColorFormat = colorFormat; - _SourcePartition = new ViewPortF(0, 0, 1, 1); - _XRatio = xRatio; - _YRatio = yRatio; - _Timing = timing; - _Flags = _Flags.SetBit(0, hwModeSetOnly); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/DisplayColorData.cs b/app/NvAPIWrapper/Native/Display/Structures/DisplayColorData.cs deleted file mode 100644 index 3a59071c..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/DisplayColorData.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct DisplayColorData : IDisplayColorData - { - private readonly ColorDataColorCoordinate _FirstColorCoordinate; - private readonly ColorDataColorCoordinate _SecondColorCoordinate; - private readonly ColorDataColorCoordinate _ThirdColorCoordinate; - private readonly ColorDataColorCoordinate _WhiteColorCoordinate; - private readonly ushort _MaximumDesiredContentLuminance; - private readonly ushort _MinimumDesiredContentLuminance; - private readonly ushort _MaximumDesiredFrameAverageLightLevel; - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate FirstColorCoordinate - { - get => _FirstColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate SecondColorCoordinate - { - get => _SecondColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate ThirdColorCoordinate - { - get => _ThirdColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate WhiteColorCoordinate - { - get => _WhiteColorCoordinate; - } - - /// - /// Gets the maximum desired content luminance [1.0-65535] in cd/m^2 - /// - public float MaximumDesiredContentLuminance - { - get => _MaximumDesiredContentLuminance; - } - - /// - /// Gets the maximum desired content frame average light level (a.k.a MaxFALL) [1.0-65535] in cd/m^2 - /// - public float MaximumDesiredContentFrameAverageLightLevel - { - get => _MaximumDesiredFrameAverageLightLevel; - } - - /// - /// Gets the maximum desired content luminance [1.0-6.5535] in cd/m^2 - /// - public float MinimumDesiredContentLuminance - { - get => _MinimumDesiredContentLuminance / 10000f; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/DisplayHandle.cs b/app/NvAPIWrapper/Native/Display/Structures/DisplayHandle.cs deleted file mode 100644 index c19e6cbd..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/DisplayHandle.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// DisplayHandle is a one-to-one map to the GDI handle of an attached display in the Windows Display Properties - /// Settings page. - /// - [StructLayout(LayoutKind.Sequential)] - public struct DisplayHandle : IHandle, IEquatable - { - internal readonly IntPtr _MemoryAddress; - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - - /// - public bool Equals(DisplayHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DisplayHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DisplayHandle left, DisplayHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DisplayHandle left, DisplayHandle right) - { - return !left.Equals(right); - } - - /// - public override string ToString() - { - return $"DisplayHandle #{MemoryAddress.ToInt64()}"; - } - - /// - /// Gets default DisplayHandle with a null pointer - /// - public static DisplayHandle DefaultHandle - { - get => default(DisplayHandle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV1.cs b/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV1.cs deleted file mode 100644 index 2da5ea07..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV1.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - [StructureVersion(1)] - public struct HDMISupportInfoV1 : IInitializable, IHDMISupportInfo - { - [FieldOffset(0)] internal StructureVersion _Version; - [FieldOffset(4)] private readonly uint _Flags; - [FieldOffset(8)] private readonly uint _EDID861ExtensionRevision; - - /// - public bool IsGPUCapableOfHDMIOutput - { - get => _Flags.GetBit(0); - } - - /// - public bool? IsMonitorCapableOfsYCC601 - { - get => null; - } - - /// - public bool IsMonitorCapableOfUnderscan - { - get => _Flags.GetBit(1); - } - - /// - public bool? IsMonitorCapableOfAdobeYCC601 - { - get => null; - } - - /// - public bool IsMonitorCapableOfBasicAudio - { - get => _Flags.GetBit(2); - } - - /// - public bool IsMonitorCapableOfYCbCr444 - { - get => _Flags.GetBit(3); - } - - /// - public bool IsMonitorCapableOfYCbCr422 - { - get => _Flags.GetBit(4); - } - - /// - // ReSharper disable once IdentifierTypo - public bool IsMonitorCapableOfxvYCC601 - { - get => _Flags.GetBit(5); - } - - /// - // ReSharper disable once IdentifierTypo - public bool IsMonitorCapableOfxvYCC709 - { - get => _Flags.GetBit(6); - } - - /// - public bool IsHDMIMonitor - { - get => _Flags.GetBit(7); - } - - /// - public bool? IsMonitorCapableOfAdobeRGB - { - get => null; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public uint EDID861ExtensionRevision - { - get => _EDID861ExtensionRevision; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV2.cs b/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV2.cs deleted file mode 100644 index 5072ad7f..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/HDMISupportInfoV2.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - [StructureVersion(2)] - public struct HDMISupportInfoV2 : IInitializable, IHDMISupportInfo - { - [FieldOffset(0)] internal StructureVersion _Version; - [FieldOffset(4)] private readonly uint _Flags; - [FieldOffset(8)] private readonly uint _EDID861ExtensionRevision; - - /// - public bool IsGPUCapableOfHDMIOutput - { - get => _Flags.GetBit(0); - } - - /// - public bool IsMonitorCapableOfUnderscan - { - get => _Flags.GetBit(1); - } - - /// - public bool IsMonitorCapableOfBasicAudio - { - get => _Flags.GetBit(2); - } - - /// - public bool IsMonitorCapableOfYCbCr444 - { - get => _Flags.GetBit(3); - } - - /// - public bool IsMonitorCapableOfYCbCr422 - { - get => _Flags.GetBit(4); - } - - /// - // ReSharper disable once IdentifierTypo - public bool IsMonitorCapableOfxvYCC601 - { - get => _Flags.GetBit(5); - } - - /// - // ReSharper disable once IdentifierTypo - public bool IsMonitorCapableOfxvYCC709 - { - get => _Flags.GetBit(6); - } - - /// - public bool IsHDMIMonitor - { - get => _Flags.GetBit(7); - } - - /// - public bool? IsMonitorCapableOfsYCC601 - { - get => _Flags.GetBit(8); - } - - /// - public bool? IsMonitorCapableOfAdobeYCC601 - { - get => _Flags.GetBit(9); - } - - /// - public bool? IsMonitorCapableOfAdobeRGB - { - get => _Flags.GetBit(10); - } - - /// - // ReSharper disable once ConvertToAutoProperty - public uint EDID861ExtensionRevision - { - get => _EDID861ExtensionRevision; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/HDRCapabilitiesV1.cs b/app/NvAPIWrapper/Native/Display/Structures/HDRCapabilitiesV1.cs deleted file mode 100644 index cda52831..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/HDRCapabilitiesV1.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding HDR capabilities of a display - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct HDRCapabilitiesV1 : IInitializable - { - internal StructureVersion _Version; - private readonly uint _RawReserved; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly StaticMetadataDescriptorId _StaticMetadataDescriptorId; - private readonly DisplayColorData _DisplayData; - - internal HDRCapabilitiesV1(bool expandDriverDefaultHDRParameters) - { - this = typeof(HDRCapabilitiesV1).Instantiate(); - _RawReserved = 0u.SetBit(3, expandDriverDefaultHDRParameters); - _StaticMetadataDescriptorId = StaticMetadataDescriptorId.StaticMetadataType1; - } - - /// - /// Gets the display color space configurations - /// - // ReSharper disable once ConvertToAutoProperty - public DisplayColorData DisplayData - { - get => _DisplayData; - } - - /// - /// Gets a boolean value indicating if the HDMI2.0a UHDA HDR with ST2084 EOTF (CEA861.3) is supported. - /// - public bool IsST2084EOTFSupported - { - get => _RawReserved.GetBit(0); - } - - /// - /// Gets a boolean value indicating if the HDMI2.0a traditional HDR gamma (CEA861.3) is supported. - /// - public bool IsTraditionalHDRGammaSupported - { - get => _RawReserved.GetBit(1); - } - - /// - /// Gets a boolean value indicating if the Extended Dynamic Range on SDR displays is supported. - /// - public bool IsEDRSupported - { - get => _RawReserved.GetBit(2); - } - - /// - /// Gets a boolean value indicating if the default EDID HDR parameters is expanded; - /// otherwise false if this instance contains actual HDR parameters. - /// - public bool IsDriverDefaultHDRParametersExpanded - { - get => _RawReserved.GetBit(3); - } - - /// - /// Gets a boolean value indicating if the HDMI2.0a traditional SDR gamma is supported. - /// - public bool IsTraditionalSDRGammaSupported - { - get => _RawReserved.GetBit(4); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV1.cs b/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV1.cs deleted file mode 100644 index 2a371321..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV1.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct HDRColorDataV1 : IInitializable, IHDRColorData - { - internal StructureVersion _Version; - private readonly ColorDataHDRCommand _Command; - private readonly ColorDataHDRMode _HDRMode; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly StaticMetadataDescriptorId _StaticMetadataDescriptorId; - private readonly MasteringDisplayColorData _MasteringDisplayData; - - /// - /// Creates an instance of . - /// - /// The command to be executed. - /// The hdr mode. - /// The display color space configurations. - public HDRColorDataV1( - ColorDataHDRCommand command, - ColorDataHDRMode hdrMode, - MasteringDisplayColorData masteringDisplayData = default - ) - { - this = typeof(HDRColorDataV1).Instantiate(); - - if (command != ColorDataHDRCommand.Set) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = command; - _HDRMode = hdrMode; - _MasteringDisplayData = masteringDisplayData; - _StaticMetadataDescriptorId = StaticMetadataDescriptorId.StaticMetadataType1; - } - - - /// - /// Creates an instance of . - /// - /// The command to be executed. - public HDRColorDataV1(ColorDataHDRCommand command) - { - this = typeof(HDRColorDataV1).Instantiate(); - - if (command != ColorDataHDRCommand.Get) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = command; - } - - /// - public ColorDataDepth? ColorDepth - { - get => null; - } - - /// - public ColorDataFormat? ColorFormat - { - get => null; - } - - /// - /// Gets the color data command - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataHDRCommand Command - { - get => _Command; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => null; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataHDRMode HDRMode - { - get => _HDRMode; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public MasteringDisplayColorData MasteringDisplayData - { - get => _MasteringDisplayData; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV2.cs b/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV2.cs deleted file mode 100644 index 2f9c9d65..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/HDRColorDataV2.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct HDRColorDataV2 : IInitializable, IHDRColorData - { - internal StructureVersion _Version; - private readonly ColorDataHDRCommand _Command; - private readonly ColorDataHDRMode _HDRMode; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly StaticMetadataDescriptorId _StaticMetadataDescriptorId; - private readonly MasteringDisplayColorData _MasteringDisplayData; - private readonly ColorDataFormat _ColorFormat; - private readonly ColorDataDynamicRange _DynamicRange; - private readonly ColorDataDepth _ColorDepth; - - /// - /// Creates an instance of . - /// - /// The command to be executed. - /// The hdr mode. - /// The display color space configurations. - /// The color data color format. - /// The color data dynamic range. - /// The color data color depth. - public HDRColorDataV2( - ColorDataHDRCommand command, - ColorDataHDRMode hdrMode, - MasteringDisplayColorData masteringDisplayData = default, - ColorDataFormat colorFormat = ColorDataFormat.Default, - ColorDataDynamicRange dynamicRange = ColorDataDynamicRange.Auto, - ColorDataDepth colorDepth = ColorDataDepth.Default - ) - { - this = typeof(HDRColorDataV2).Instantiate(); - - if (command != ColorDataHDRCommand.Set) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = command; - _HDRMode = hdrMode; - _MasteringDisplayData = masteringDisplayData; - _ColorFormat = colorFormat; - _DynamicRange = dynamicRange; - _ColorDepth = colorDepth; - _StaticMetadataDescriptorId = StaticMetadataDescriptorId.StaticMetadataType1; - } - - /// - /// Creates an instance of . - /// - /// The command to be executed. - public HDRColorDataV2(ColorDataHDRCommand command) - { - this = typeof(HDRColorDataV2).Instantiate(); - - if (command != ColorDataHDRCommand.Get) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = command; - } - - /// - /// Gets the color data command - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataHDRCommand Command - { - get => _Command; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataHDRMode HDRMode - { - get => _HDRMode; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public MasteringDisplayColorData MasteringDisplayData - { - get => _MasteringDisplayData; - } - - /// - public ColorDataFormat? ColorFormat - { - get => _ColorFormat; - } - - /// - public ColorDataDynamicRange? DynamicRange - { - get => _DynamicRange; - } - - /// - public ColorDataDepth? ColorDepth - { - get - { - switch ((uint) _ColorDepth) - { - case 6: - return ColorDataDepth.BPC6; - case 8: - return ColorDataDepth.BPC8; - case 10: - return ColorDataDepth.BPC10; - case 12: - return ColorDataDepth.BPC12; - case 16: - return ColorDataDepth.BPC16; - default: - return _ColorDepth; - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameAudio.cs b/app/NvAPIWrapper/Native/Display/Structures/InfoFrameAudio.cs deleted file mode 100644 index 53897075..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameAudio.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains info-frame audio information - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - public struct InfoFrameAudio - { - [FieldOffset(0)] private readonly uint _WordAt0; - - [FieldOffset(4)] private readonly uint _WordAt4; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - [FieldOffset(8)] private readonly uint _WordAt8; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - [FieldOffset(12)] private readonly byte _ByteAt12; - - /// - /// Creates an instance of . - /// - /// The audio coding type (codec) - /// The audio codec from codec extension - /// The audio sample size (depth) - /// The audio sample rate (sampling frequency) - /// The number of audio channels - /// The audio channel allocation (speaker placements) - /// A value indicating if down-mix is prohibited - /// The Low Frequency Effects playback level value - /// The audio level shift value - public InfoFrameAudio( - InfoFrameAudioCodec codec, - InfoFrameAudioExtendedCodec codecExtension, - InfoFrameAudioSampleSize sampleSize, - InfoFrameAudioSampleRate sampleRate, - InfoFrameAudioChannelCount channelCount, - InfoFrameAudioChannelAllocation channelAllocation, - InfoFrameBoolean isDownMixProhibited, - InfoFrameAudioLFEPlaybackLevel lfePlaybackLevel, - InfoFrameAudioLevelShift levelShift - ) - { - _WordAt0 = 0u - .SetBits(0, 5, (uint) codec) - .SetBits(5, 6, (uint) codecExtension) - .SetBits(11, 3, (uint) sampleSize) - .SetBits(14, 4, (uint) sampleRate) - .SetBits(18, 4, (uint) channelCount) - .SetBits(22, 9, (uint) channelAllocation); - _WordAt4 = 0u - .SetBits(0, 2, (uint) isDownMixProhibited) - .SetBits(2, 3, (uint) lfePlaybackLevel) - .SetBits(5, 5, (uint) levelShift); - _WordAt8 = 0; - _ByteAt12 = 0; - } - - /// - /// Gets the audio coding type (codec) - /// - public InfoFrameAudioCodec Codec - { - get => (InfoFrameAudioCodec) _WordAt0.GetBits(0, 5); - } - - /// - /// Gets the audio codec from codec extension; only valid when - /// == - /// - public InfoFrameAudioExtendedCodec? ExtendedCodec - { - get - { - if (Codec != InfoFrameAudioCodec.UseExtendedCodecType) - { - return null; - } - - return (InfoFrameAudioExtendedCodec) _WordAt0.GetBits(5, 6); - } - } - - /// - /// Gets the audio sample size (depth) - /// - public InfoFrameAudioSampleSize SampleSize - { - get => (InfoFrameAudioSampleSize) _WordAt0.GetBits(11, 3); - } - - /// - /// Gets the audio sample rate (sampling frequency) - /// - public InfoFrameAudioSampleRate SampleRate - { - get => (InfoFrameAudioSampleRate) _WordAt0.GetBits(14, 4); - } - - /// - /// Gets the number of audio channels - /// - public InfoFrameAudioChannelCount ChannelCount - { - get => (InfoFrameAudioChannelCount) _WordAt0.GetBits(18, 4); - } - - /// - /// Gets the audio channel allocation (speaker placements) - /// - public InfoFrameAudioChannelAllocation ChannelAllocation - { - get => (InfoFrameAudioChannelAllocation) _WordAt0.GetBits(22, 9); - } - - /// - /// Gets a value indicating if down-mix is prohibited - /// - public InfoFrameBoolean IsDownMixProhibited - { - get => (InfoFrameBoolean) _WordAt4.GetBits(0, 2); - } - - /// - /// Gets the Low Frequency Effects playback level value - /// - public InfoFrameAudioLFEPlaybackLevel LFEPlaybackLevel - { - get => (InfoFrameAudioLFEPlaybackLevel) _WordAt4.GetBits(2, 3); - } - - /// - /// Gets the audio level shift value - /// - public InfoFrameAudioLevelShift LevelShift - { - get => (InfoFrameAudioLevelShift) _WordAt4.GetBits(5, 5); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameData.cs b/app/NvAPIWrapper/Native/Display/Structures/InfoFrameData.cs deleted file mode 100644 index d90ded17..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameData.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains info-frame requested information or information to be overriden - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - [StructureVersion(1)] - public struct InfoFrameData : IInitializable - { - [FieldOffset(0)] internal StructureVersion _Version; - - [FieldOffset(4)] - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly ushort _Size; - - [FieldOffset(6)] - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly byte _Command; - - [FieldOffset(7)] private readonly byte _Type; - - [FieldOffset(8)] private readonly InfoFrameProperty _Property; - [FieldOffset(8)] private readonly InfoFrameAudio _Audio; - [FieldOffset(8)] private readonly InfoFrameVideo _Video; - - /// - /// Creates a new instance of . - /// - /// - /// The operation to be done. Can be used for information retrieval or to reset configurations to - /// default. - /// - /// The type of information. - public InfoFrameData(InfoFrameCommand command, InfoFrameDataType dataType) - { - this = typeof(InfoFrameData).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != InfoFrameCommand.Get && - command != InfoFrameCommand.GetDefault && - command != InfoFrameCommand.GetOverride && - command != InfoFrameCommand.GetProperty && - command != InfoFrameCommand.Reset) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Type = (byte) dataType; - } - - /// - /// Creates a new instance of . - /// - /// The operation to be done. Can only be used to change property information. - /// The type of information. - /// The new property information to be set. - public InfoFrameData( - InfoFrameCommand command, - InfoFrameDataType dataType, - InfoFrameProperty propertyInformation) - { - this = typeof(InfoFrameData).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != InfoFrameCommand.SetProperty) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Type = (byte) dataType; - _Property = propertyInformation; - } - - /// - /// Creates a new instance of . - /// - /// The operation to be done. Can only be used to change current or default audio information. - /// The new audio information to be set. - public InfoFrameData(InfoFrameCommand command, InfoFrameAudio audioInformation) - { - this = typeof(InfoFrameData).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != InfoFrameCommand.Set && - command != InfoFrameCommand.SetOverride) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Type = (byte) InfoFrameDataType.AudioInformation; - _Audio = audioInformation; - } - - /// - /// Creates a new instance of . - /// - /// The operation to be done. Can only be used to change current or default video information. - /// The new video information to be set. - public InfoFrameData(InfoFrameCommand command, InfoFrameVideo videoInformation) - { - this = typeof(InfoFrameData).Instantiate(); - _Size = (ushort) _Version.StructureSize; - - if (command != InfoFrameCommand.Set && - command != InfoFrameCommand.SetOverride) - { - throw new ArgumentOutOfRangeException(nameof(command)); - } - - _Command = (byte) command; - _Type = (byte) InfoFrameDataType.AuxiliaryVideoInformation; - _Video = videoInformation; - } - - /// - /// Gets the type of data contained in this instance - /// - public InfoFrameDataType Type - { - get => (InfoFrameDataType) _Type; - } - - /// - /// Gets the operation type - /// - public InfoFrameCommand Command - { - get => (InfoFrameCommand) _Command; - } - - /// - /// Gets the info-frame audio information if available; otherwise null - /// - public InfoFrameAudio? AudioInformation - { - get - { - if (Command == InfoFrameCommand.GetProperty || Command == InfoFrameCommand.SetProperty) - { - return null; - } - - if (Type == InfoFrameDataType.AudioInformation) - { - return _Audio; - } - - return null; - } - } - - /// - /// Gets the info-frame auxiliary video information (AVI) if available; otherwise null - /// - public InfoFrameVideo? AuxiliaryVideoInformation - { - get - { - if (Command == InfoFrameCommand.GetProperty || Command == InfoFrameCommand.SetProperty) - { - return null; - } - - if (Type == InfoFrameDataType.AuxiliaryVideoInformation) - { - return _Video; - } - - return null; - } - } - - /// - /// Gets the info-frame property information if available; otherwise null - /// - public InfoFrameProperty? PropertyInformation - { - get - { - if (Command != InfoFrameCommand.GetProperty && Command != InfoFrameCommand.SetProperty) - { - return null; - } - - return _Property; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameProperty.cs b/app/NvAPIWrapper/Native/Display/Structures/InfoFrameProperty.cs deleted file mode 100644 index 1489be57..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameProperty.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains info-frame property information - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - public struct InfoFrameProperty - { - [FieldOffset(0)] private readonly uint _Word; - - /// - /// Creates an instance of . - /// - /// The info-frame operation mode - /// A value indicating if this display (monitor) is blacklisted - public InfoFrameProperty(InfoFramePropertyMode mode, InfoFrameBoolean isBlackListed) - { - _Word = 0u - .SetBits(0, 4, (uint) mode) - .SetBits(4, 2, (uint) isBlackListed); - } - - /// - /// Gets the info-frame operation mode - /// - public InfoFramePropertyMode Mode - { - get => (InfoFramePropertyMode) _Word.GetBits(0, 4); - } - - /// - /// Gets a value indicating if this display (monitor) is blacklisted - /// - public InfoFrameBoolean IsBlackListed - { - get => (InfoFrameBoolean) _Word.GetBits(4, 2); - } - - /// - /// Gets the info-frame version - /// - public byte Version - { - get => (byte) _Word.GetBits(16, 8); - } - - /// - /// Gets the info-frame length - /// - public byte Length - { - get => (byte) _Word.GetBits(24, 8); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs b/app/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs deleted file mode 100644 index a366bda9..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/InfoFrameVideo.cs +++ /dev/null @@ -1,320 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains info-frame video information - /// - [StructLayout(LayoutKind.Explicit, Pack = 8)] - public struct InfoFrameVideo - { - [FieldOffset(0)] private readonly uint _WordAt0; - [FieldOffset(4)] private readonly uint _WordAt4; - [FieldOffset(8)] private readonly uint _WordAt8; - [FieldOffset(12)] private readonly uint _WordAt12; - [FieldOffset(16)] private readonly uint _WordAt16; - [FieldOffset(20)] private readonly uint _WordAt20; - - /// - /// Creates an instance of . - /// - /// The video identification code (VIC) - /// The video pixel repetition - /// The video color format - /// The video color space - /// The extended video color space - /// The RGB quantization configuration - /// The YCC quantization configuration - /// The video content mode - /// The video content type - /// The video scan information - /// A value indicating if the active format information is present - /// The active format aspect ratio - /// The picture aspect ratio - /// The non uniform picture scaling direction - /// The video bar information - /// The top bar value if not auto and present; otherwise null - /// The bottom bar value if not auto and present; otherwise null - /// The left bar value if not auto and present; otherwise null - /// The right bar value if not auto and present; otherwise null - public InfoFrameVideo( - byte videoIdentificationCode, - InfoFrameVideoPixelRepetition pixelRepetition, - InfoFrameVideoColorFormat colorFormat, - InfoFrameVideoColorimetry colorimetry, - InfoFrameVideoExtendedColorimetry extendedColorimetry, - InfoFrameVideoRGBQuantization rgbQuantization, - InfoFrameVideoYCCQuantization yccQuantization, - InfoFrameVideoITC contentMode, - InfoFrameVideoContentType contentType, - InfoFrameVideoScanInfo scanInfo, - InfoFrameBoolean isActiveFormatInfoPresent, - InfoFrameVideoAspectRatioActivePortion activeFormatAspectRatio, - InfoFrameVideoAspectRatioCodedFrame pictureAspectRatio, - InfoFrameVideoNonUniformPictureScaling nonUniformPictureScaling, - InfoFrameVideoBarData barInfo, - uint? topBar, - uint? bottomBar, - uint? leftBar, - uint? rightBar - ) - { - _WordAt0 = 0u - .SetBits(0, 8, videoIdentificationCode) - .SetBits(8, 5, (uint) pixelRepetition) - .SetBits(13, 3, (uint) colorFormat) - .SetBits(16, 3, (uint) colorimetry) - .SetBits(19, 4, (uint) extendedColorimetry) - .SetBits(23, 3, (uint) rgbQuantization) - .SetBits(26, 3, (uint) yccQuantization) - .SetBits(29, 2, (uint) contentMode); - - _WordAt4 = 0u - .SetBits(0, 3, (uint) contentType) - .SetBits(3, 3, (uint) scanInfo) - .SetBits(6, 2, (uint) isActiveFormatInfoPresent) - .SetBits(8, 5, (uint) activeFormatAspectRatio) - .SetBits(13, 3, (uint) pictureAspectRatio) - .SetBits(16, 3, (uint) nonUniformPictureScaling) - .SetBits(19, 3, (uint) barInfo); - - _WordAt8 = topBar == null ? 0x1FFFF : 0u.SetBits(0, 17, topBar.Value); - _WordAt12 = bottomBar == null ? 0x1FFFF : 0u.SetBits(0, 17, bottomBar.Value); - _WordAt16 = leftBar == null ? 0x1FFFF : 0u.SetBits(0, 17, leftBar.Value); - _WordAt20 = rightBar == null ? 0x1FFFF : 0u.SetBits(0, 17, rightBar.Value); - } - - /// - /// Gets the video identification code (VIC) - /// - // ReSharper disable once ConvertToAutoProperty - public byte? VideoIdentificationCode - { - get - { - var value = (byte) _WordAt0.GetBits(0, 8); - - if (value == 0xFF) - { - return null; - } - - return value; - } - } - - /// - /// Gets the video pixel repetition - /// - public InfoFrameVideoPixelRepetition PixelRepetition - { - get => (InfoFrameVideoPixelRepetition) _WordAt0.GetBits(8, 5); - } - - /// - /// Gets the video color format - /// - public InfoFrameVideoColorFormat ColorFormat - { - get => (InfoFrameVideoColorFormat) _WordAt0.GetBits(13, 3); - } - - /// - /// Gets the video color space - /// - public InfoFrameVideoColorimetry Colorimetry - { - get => (InfoFrameVideoColorimetry) _WordAt0.GetBits(16, 3); - } - - /// - /// Gets the extended video color space; only valid when == - /// - /// - public InfoFrameVideoExtendedColorimetry? ExtendedColorimetry - { - get - { - if (Colorimetry != InfoFrameVideoColorimetry.UseExtendedColorimetry) - { - return null; - } - - return (InfoFrameVideoExtendedColorimetry) _WordAt0.GetBits(19, 4); - } - } - - /// - /// Gets the RGB quantization configuration - /// - public InfoFrameVideoRGBQuantization RGBQuantization - { - get => (InfoFrameVideoRGBQuantization) _WordAt0.GetBits(23, 3); - } - - /// - /// Gets the YCC quantization configuration - /// - public InfoFrameVideoYCCQuantization YCCQuantization - { - get => (InfoFrameVideoYCCQuantization) _WordAt0.GetBits(26, 3); - } - - /// - /// Gets the video content mode - /// - public InfoFrameVideoITC ContentMode - { - get => (InfoFrameVideoITC) _WordAt0.GetBits(29, 2); - } - - /// - /// Gets the video content type - /// - public InfoFrameVideoContentType ContentType - { - get => (InfoFrameVideoContentType) _WordAt4.GetBits(0, 3); - } - - /// - /// Gets the video scan information - /// - public InfoFrameVideoScanInfo ScanInfo - { - get => (InfoFrameVideoScanInfo) _WordAt4.GetBits(3, 3); - } - - /// - /// Gets a value indicating if the active format information is present - /// - public InfoFrameBoolean IsActiveFormatInfoPresent - { - get => (InfoFrameBoolean) _WordAt4.GetBits(6, 2); - } - - /// - /// Gets the active format aspect ratio - /// - public InfoFrameVideoAspectRatioActivePortion ActiveFormatAspectRatio - { - get => (InfoFrameVideoAspectRatioActivePortion) _WordAt4.GetBits(8, 5); - } - - /// - /// Gets the picture aspect ratio - /// - public InfoFrameVideoAspectRatioCodedFrame PictureAspectRatio - { - get => (InfoFrameVideoAspectRatioCodedFrame) _WordAt4.GetBits(13, 3); - } - - /// - /// Gets the non uniform picture scaling direction - /// - public InfoFrameVideoNonUniformPictureScaling NonUniformPictureScaling - { - get => (InfoFrameVideoNonUniformPictureScaling) _WordAt4.GetBits(16, 3); - } - - /// - /// Gets the video bar information - /// - public InfoFrameVideoBarData BarInfo - { - get => (InfoFrameVideoBarData) _WordAt4.GetBits(19, 3); - } - - /// - /// Gets the top bar value if not auto and present; otherwise null - /// - public uint? TopBar - { - get - { - if (BarInfo == InfoFrameVideoBarData.NotPresent || BarInfo == InfoFrameVideoBarData.Horizontal) - { - return null; - } - - var val = _WordAt8.GetBits(0, 17); - - if (val == 0x1FFFF) - { - return null; - } - - return (uint) val; - } - } - - /// - /// Gets the bottom bar value if not auto and present; otherwise null - /// - public uint? BottomBar - { - get - { - if (BarInfo == InfoFrameVideoBarData.NotPresent || BarInfo == InfoFrameVideoBarData.Horizontal) - { - return null; - } - - var val = _WordAt12.GetBits(0, 17); - - if (val == 0x1FFFF) - { - return null; - } - - return (uint) val; - } - } - - /// - /// Gets the left bar value if not auto and present; otherwise null - /// - public uint? LeftBar - { - get - { - if (BarInfo == InfoFrameVideoBarData.NotPresent || BarInfo == InfoFrameVideoBarData.Vertical) - { - return null; - } - - var val = _WordAt16.GetBits(0, 17); - - if (val == 0x1FFFF) - { - return null; - } - - return (uint) val; - } - } - - /// - /// Gets the right bar value if not auto and present; otherwise null - /// - public uint? RightBar - { - get - { - if (BarInfo == InfoFrameVideoBarData.NotPresent || BarInfo == InfoFrameVideoBarData.Vertical) - { - return null; - } - - var val = _WordAt20.GetBits(0, 17); - - if (val == 0x1FFFF) - { - return null; - } - - return (uint) val; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/LUID.cs b/app/NvAPIWrapper/Native/Display/Structures/LUID.cs deleted file mode 100644 index 1af8cae5..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/LUID.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Locally unique identifier is a 64-bit value guaranteed to be unique only on the system on which it was generated. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct LUID : IEquatable - { - /// - /// 32Bit unsigned integer, low - /// - public readonly uint LowPart; - - /// - /// 32Bit signed integer, high - /// - public readonly int HighPart; - - /// - public override string ToString() - { - return $"{{{LowPart:X}-{HighPart:X}}}"; - } - - /// - public bool Equals(LUID other) - { - return LowPart == other.LowPart && HighPart == other.HighPart; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is LUID luid && Equals(luid); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(LUID left, LUID right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(LUID left, LUID right) - { - return !left.Equals(right); - } - - /// - public override int GetHashCode() - { - unchecked - { - return ((int) LowPart * 397) ^ HighPart; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/MasteringDisplayColorData.cs b/app/NvAPIWrapper/Native/Display/Structures/MasteringDisplayColorData.cs deleted file mode 100644 index 0a0f2daa..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/MasteringDisplayColorData.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct MasteringDisplayColorData : IDisplayColorData - { - private readonly ColorDataColorCoordinate _FirstColorCoordinate; - private readonly ColorDataColorCoordinate _SecondColorCoordinate; - private readonly ColorDataColorCoordinate _ThirdColorCoordinate; - private readonly ColorDataColorCoordinate _WhiteColorCoordinate; - private readonly ushort _MaximumMasteringLuminance; - private readonly ushort _MinimumMasteringLuminance; - private readonly ushort _MaximumContentLightLevel; - private readonly ushort _MaximumFrameAverageLightLevel; - - /// - /// Creates an instance of . - /// - /// The first primary color coordinate. - /// The second primary color coordinate. - /// The third primary color coordinate. - /// The white color coordinate. - /// The maximum mastering display luminance [1.0-65535] in cd/m^2 - /// The maximum mastering display luminance [1.0-6.5535] in cd/m^2 - /// - /// The maximum mastering display content light level (a.k.a MaxCLL) [1.0-65535] in - /// cd/m^2 - /// - /// - /// The maximum mastering display frame average light level (a.k.a MaxFALL) - /// [1.0-65535] in cd/m^2 - /// - public MasteringDisplayColorData( - ColorDataColorCoordinate firstColorCoordinate, - ColorDataColorCoordinate secondColorCoordinate, - ColorDataColorCoordinate thirdColorCoordinate, - ColorDataColorCoordinate whiteColorCoordinate, - float maximumMasteringLuminance, - float minimumMasteringLuminance, - float maximumContentLightLevel, - float maximumFrameAverageLightLevel - ) - { - _FirstColorCoordinate = firstColorCoordinate; - _SecondColorCoordinate = secondColorCoordinate; - _ThirdColorCoordinate = thirdColorCoordinate; - _WhiteColorCoordinate = whiteColorCoordinate; - _MaximumMasteringLuminance = (ushort) Math.Max(Math.Min(maximumMasteringLuminance, uint.MaxValue), 1); - _MinimumMasteringLuminance = - (ushort) Math.Max(Math.Min(minimumMasteringLuminance * 10000, uint.MaxValue), 1); - _MaximumContentLightLevel = (ushort) Math.Max(Math.Min(maximumContentLightLevel, uint.MaxValue), 1); - _MaximumFrameAverageLightLevel = - (ushort) Math.Max(Math.Min(maximumFrameAverageLightLevel, uint.MaxValue), 1); - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate FirstColorCoordinate - { - get => _FirstColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate SecondColorCoordinate - { - get => _SecondColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate ThirdColorCoordinate - { - get => _ThirdColorCoordinate; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public ColorDataColorCoordinate WhiteColorCoordinate - { - get => _WhiteColorCoordinate; - } - - /// - /// Gets the maximum mastering display luminance [1.0-65535] in cd/m^2 - /// - public float MaximumMasteringLuminance - { - get => _MaximumMasteringLuminance; - } - - /// - /// Gets the maximum mastering display frame average light level (a.k.a MaxFALL) [1.0-65535] in cd/m^2 - /// - public float MaximumFrameAverageLightLevel - { - get => _MaximumFrameAverageLightLevel; - } - - /// - /// Gets the maximum mastering display content light level (a.k.a MaxCLL) [1.0-65535] in cd/m^2 - /// - public float MaximumContentLightLevel - { - get => _MaximumContentLightLevel; - } - - /// - /// Gets the maximum mastering display luminance [1.0-6.5535] in cd/m^2 - /// - public float MinimumMasteringLuminance - { - get => _MinimumMasteringLuminance / 10000f; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/MonitorCapabilities.cs b/app/NvAPIWrapper/Native/Display/Structures/MonitorCapabilities.cs deleted file mode 100644 index 8d388510..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/MonitorCapabilities.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains the monitor capabilities read from the Vendor Specific Data Block or the Video Capability Data Block - /// - [StructureVersion(1)] - [StructLayout(LayoutKind.Explicit, Pack = 8)] - public struct MonitorCapabilities : IInitializable - { - [FieldOffset(0)] internal StructureVersion _Version; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - [FieldOffset(4)] private readonly ushort _Size; - [FieldOffset(8)] private readonly MonitorCapabilitiesType _Type; - [FieldOffset(12)] private readonly MonitorCapabilitiesConnectorType _ConnectorType; - - [FieldOffset(16)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)] - private readonly byte[] _Data; - - /// - /// Creates a new instance of . - /// - /// The type of information to be retrieved. - public MonitorCapabilities(MonitorCapabilitiesType type) - { - this = typeof(MonitorCapabilities).Instantiate(); - _Size = (ushort) _Version.StructureSize; - _Type = type; - } - - /// - /// Gets a boolean value indicating if this instance contains valid information - /// - public bool IsValid - { - get => _Data[0].GetBit(0); - } - - /// - /// Gets the monitor capability type - /// - // ReSharper disable once ConvertToAutoPropertyWhenPossible - public MonitorCapabilitiesType Type - { - get => _Type; - } - - /// - /// Gets the monitor connector type - /// - // ReSharper disable once ConvertToAutoProperty - public MonitorCapabilitiesConnectorType ConnectorType - { - get => _ConnectorType; - } - - /// - /// Gets the monitor VCDB capabilities information - /// - public MonitorVCDBCapabilities? VCDBCapabilities - { - get - { - if (IsValid && _Type == MonitorCapabilitiesType.VCDB) - { - return new MonitorVCDBCapabilities(_Data.Skip(1).ToArray()); - } - - return null; - } - } - - /// - /// Gets the monitor VSDB capabilities information - /// - public MonitorVSDBCapabilities? VSDBCapabilities - { - get - { - if (IsValid && _Type == MonitorCapabilitiesType.VSDB) - { - return new MonitorVSDBCapabilities(_Data.Skip(1).ToArray()); - } - - return null; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/MonitorColorData.cs b/app/NvAPIWrapper/Native/Display/Structures/MonitorColorData.cs deleted file mode 100644 index 4cfe3a53..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/MonitorColorData.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information about a monitor color data - /// - [StructureVersion(1)] - [StructLayout(LayoutKind.Explicit, Pack = 8, Size = 12)] - public struct MonitorColorData : IInitializable - { - [FieldOffset(0)] - internal StructureVersion _Version; - [FieldOffset(4)] - private readonly DisplayPortColorFormat _ColorFormat; - [FieldOffset(8)] - private readonly DisplayPortColorDepth _ColorDepth; - - /// - ///Gets the monitor display port color format - /// - // ReSharper disable once ConvertToAutoProperty - public DisplayPortColorFormat ColorFormat - { - get => _ColorFormat; - } - - /// - /// Gets the monitor display port color depth - /// - // ReSharper disable once ConvertToAutoProperty - public DisplayPortColorDepth ColorDepth - { - get - { - switch ((uint) _ColorDepth) - { - case 6: - return DisplayPortColorDepth.BPC6; - case 8: - return DisplayPortColorDepth.BPC8; - case 10: - return DisplayPortColorDepth.BPC10; - case 12: - return DisplayPortColorDepth.BPC12; - case 16: - return DisplayPortColorDepth.BPC16; - default: - return _ColorDepth; - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/MonitorVCDBCapabilities.cs b/app/NvAPIWrapper/Native/Display/Structures/MonitorVCDBCapabilities.cs deleted file mode 100644 index 7305b7a0..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/MonitorVCDBCapabilities.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains monitor VCDB capabilities - /// - public struct MonitorVCDBCapabilities - { - private readonly byte[] _data; - - internal MonitorVCDBCapabilities(byte[] data) - { - if (data.Length != 49) - { - throw new ArgumentOutOfRangeException(nameof(data)); - } - - _data = data; - } - - /// - /// Gets a boolean value indicating RGB range quantization - /// - public bool QuantizationRangeRGB - { - get => _data[0].GetBit(1); - } - - /// - /// Gets a boolean value indicating Ycc range quantization - /// - public bool QuantizationRangeYcc - { - get => _data[0].GetBit(0); - } - - public byte ScanInfoConsumerElectronicsVideoFormats - { - get => (byte)_data[0].GetBits(6, 2); - } - - public byte ScanInfoInformationTechnologyVideoFormats - { - get => (byte)_data[0].GetBits(4, 2); - } - - public byte ScanInfoPreferredVideoFormat - { - get => (byte)_data[0].GetBits(2, 2); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/MonitorVSDBCapabilities.cs b/app/NvAPIWrapper/Native/Display/Structures/MonitorVSDBCapabilities.cs deleted file mode 100644 index b81cdfdd..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/MonitorVSDBCapabilities.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains monitor VSDB capabilities - /// - public struct MonitorVSDBCapabilities - { - private readonly byte[] _data; - - internal MonitorVSDBCapabilities(byte[] data) - { - if (data.Length != 49) - { - throw new ArgumentOutOfRangeException(nameof(data)); - } - - _data = data; - } - - /// - /// Gets the audio latency if available or null - /// - public byte? AudioLatency - { - get - { - if (!_data[4].GetBit(7)) - { - return null; - } - - return _data[6]; - } - } - - public byte[] HDMI3D - { - get - { - if (!_data[9].GetBit(7)) - { - return new byte[0]; - } - - return _data.Skip(18).Take(31).Take((int)_data[10].GetBits(0, 5)).ToArray(); - } - } - - public byte[] HDMIVideoImageCompositors - { - get - { - if (!_data[4].GetBit(5)) - { - return new byte[0]; - } - - return _data.Skip(11).Take(7).Take((int)_data[10].GetBits(5, 3)).ToArray(); - } - } - - /// - /// Gets the interlaced audio latency if available or null - /// - public byte? InterlacedAudioLatency - { - get - { - if (!_data[4].GetBit(6)) - { - return null; - } - - return _data[8]; - } - } - - /// - /// Gets the interlaced video latency if available or null - /// - public byte? InterlacedVideoLatency - { - get - { - if (!_data[4].GetBit(6)) - { - return null; - } - - return _data[7]; - } - } - - public bool IsAISupported - { - get => _data[2].GetBit(7); - } - - /// - /// Returns a boolean value indicating if the cinematic content is supported by the monitor or the connection - /// - public bool IsCinemaContentSupported - { - get => _data[4].GetBit(2); - } - - /// - /// Returns a boolean value indicating if the 30bit deep color is supported by the monitor or the connection - /// - public bool IsDeepColor30BitsSupported - { - get => _data[2].GetBit(4); - } - - /// - /// Returns a boolean value indicating if the 36bit deep color is supported by the monitor or the connection - /// - public bool IsDeepColor36BitsSupported - { - get => _data[2].GetBit(5); - } - - /// - /// Returns a boolean value indicating if the 48bit deep color is supported by the monitor or the connection - /// - public bool IsDeepColor48BitsSupported - { - get => _data[2].GetBit(6); - } - - - /// - /// Returns a boolean value indicating if the YCbCr444 deep color is supported by the monitor or the connection - /// - public bool IsDeepColorYCbCr444Supported - { - get => _data[2].GetBit(3); - } - - /// - /// Returns a boolean value indicating if the dual DVI operation is supported by the monitor or the connection - /// - public bool IsDualDVIOperationSupported - { - get => _data[2].GetBit(0); - } - - /// - /// Returns a boolean value indicating if the gaming content is supported by the monitor or the connection - /// - public bool IsGameContentSupported - { - get => _data[4].GetBit(3); - } - - /// - /// Returns a boolean value indicating if the graphics text content is supported by the monitor or the connection - /// - public bool IsGraphicsTextContentSupported - { - get => _data[4].GetBit(0); - } - - /// - /// Returns a boolean value indicating if the photo content is supported by monitor or the connection - /// - public bool IsPhotoContentSupported - { - get => _data[4].GetBit(1); - } - - /// - /// Gets the connection max TMDS clock supported by the monitor or the connection - /// - public byte MaxTMDSClock - { - get => _data[3]; - } - - /// - /// Gets the monitor physical address on port - /// - public MonitorPhysicalAddress PhysicalAddress - { - get => new MonitorPhysicalAddress( - (byte)_data[0].GetBits(4, 4), - (byte)_data[0].GetBits(0, 4), - (byte)_data[1].GetBits(4, 4), - (byte)_data[1].GetBits(0, 4) - ); - } - - /// - /// Gets the video latency if available or null - /// - public byte? VideoLatency - { - get - { - if (!_data[4].GetBit(7)) - { - return null; - } - - return _data[5]; - } - } - - /// - /// Represents a monitor physical address - /// - public class MonitorPhysicalAddress - { - internal MonitorPhysicalAddress(byte a, byte b, byte c, byte d) - { - A = a; - B = b; - C = c; - D = d; - } - - /// - /// Gets the first part of a monitor physical address - /// - public byte A { get; set; } - - /// - /// Gets the second part of a monitor physical address - /// - public byte B { get; set; } - - - /// - /// Gets the third part of a monitor physical address - /// - public byte C { get; set; } - - /// - /// Gets the forth part of a monitor physical address - /// - public byte D { get; set; } - - /// - public override string ToString() - { - return $"{A:D}.{B:D}.{C:D}.{D:D}"; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PathAdvancedTargetInfo.cs b/app/NvAPIWrapper/Native/Display/Structures/PathAdvancedTargetInfo.cs deleted file mode 100644 index 73e649ae..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PathAdvancedTargetInfo.cs +++ /dev/null @@ -1,268 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds advanced information about a PathTargetInfo - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PathAdvancedTargetInfo : IInitializable, IEquatable - { - internal StructureVersion _Version; - internal readonly Rotate _Rotation; - internal readonly Scaling _Scaling; - internal readonly uint _RefreshRateInMillihertz; - internal uint _RawReserved; - internal readonly ConnectorType _ConnectorType; - internal readonly TVFormat _TVFormat; - internal readonly TimingOverride _TimingOverride; - internal readonly Timing _Timing; - - /// - /// Creates a new PathAdvancedTargetInfo for monitors - /// - /// Screen rotation - /// Screen scaling - /// Screen refresh rate - /// Timing override - /// Indicates if the mode is interlaced - /// Indicates if the display is the primary display of a clone topology - /// Indicates if the target Pan and Scan is enabled - /// - /// - /// - public PathAdvancedTargetInfo( - Rotate rotation, - Scaling scale, - uint refreshRateInMillihertz = 0, - TimingOverride timingOverride = TimingOverride.Current, - bool isInterlaced = false, - bool isClonePrimary = false, - bool isClonePanAndScanTarget = false, - bool disableVirtualModeSupport = false, - bool isPreferredUnscaledTarget = false) - { - if (timingOverride == TimingOverride.Custom) - { - throw new NVIDIANotSupportedException("Custom timing is not supported yet."); - } - - this = typeof(PathAdvancedTargetInfo).Instantiate(); - _Rotation = rotation; - _Scaling = scale; - _RefreshRateInMillihertz = refreshRateInMillihertz; - _TimingOverride = timingOverride; - IsInterlaced = isInterlaced; - IsClonePrimary = isClonePrimary; - IsClonePanAndScanTarget = isClonePanAndScanTarget; - DisableVirtualModeSupport = disableVirtualModeSupport; - IsPreferredUnscaledTarget = isPreferredUnscaledTarget; - } - - /// - /// Creates a new PathAdvancedTargetInfo for TVs - /// - /// Screen rotation - /// Screen scaling - /// The TV format to apply - /// Specify connector type. For TV only - /// Screen refresh rate - /// Timing override - /// Indicates if the mode is interlaced - /// Indicates if the display is the primary display of a clone topology - /// Indicates if the target Pan and Scan is enabled - /// - /// - /// - public PathAdvancedTargetInfo( - Rotate rotation, - Scaling scale, - TVFormat tvFormat, - ConnectorType connectorType, - uint refreshRateInMillihertz = 0, - TimingOverride timingOverride = TimingOverride.Current, - bool isInterlaced = false, - bool isClonePrimary = false, - bool isClonePanAndScanTarget = false, - bool disableVirtualModeSupport = false, - bool isPreferredUnscaledTarget = false) - : this( - rotation, scale, refreshRateInMillihertz, timingOverride, isInterlaced, isClonePrimary, - isClonePanAndScanTarget, - disableVirtualModeSupport, isPreferredUnscaledTarget) - { - if (tvFormat == TVFormat.None) - { - throw new NVIDIANotSupportedException( - "This overload is for TV displays, use the other overload(s) if the display is not a TV."); - } - - this = typeof(PathAdvancedTargetInfo).Instantiate(); - _TVFormat = tvFormat; - _ConnectorType = connectorType; - } - - /// - public bool Equals(PathAdvancedTargetInfo other) - { - return _Rotation == other._Rotation && - _Scaling == other._Scaling && - _RefreshRateInMillihertz == other._RefreshRateInMillihertz && - (TVFormat == TVFormat.None || _ConnectorType == other._ConnectorType) && - _TVFormat == other._TVFormat && - _TimingOverride == other._TimingOverride && - _Timing.Equals(other._Timing) && - _RawReserved == other._RawReserved; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PathAdvancedTargetInfo info && Equals(info); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Rotation; - hashCode = (hashCode * 397) ^ (int) _Scaling; - hashCode = (hashCode * 397) ^ (int) _RefreshRateInMillihertz; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ (int) _RawReserved; - hashCode = (hashCode * 397) ^ (int) _ConnectorType; - hashCode = (hashCode * 397) ^ (int) _TVFormat; - hashCode = (hashCode * 397) ^ (int) _TimingOverride; - hashCode = (hashCode * 397) ^ _Timing.GetHashCode(); - - return hashCode; - } - } - - /// - /// Rotation setting - /// - public Rotate Rotation - { - get => _Rotation; - } - - /// - /// Scaling setting - /// - public Scaling Scaling - { - get => _Scaling; - } - - /// - /// Non-interlaced Refresh Rate of the mode, multiplied by 1000, 0 = ignored - /// This is the value which driver reports to the OS. - /// - public uint RefreshRateInMillihertz - { - get => _RefreshRateInMillihertz; - } - - /// - /// Specify connector type. For TV only, ignored if TVFormat == TVFormat.None. - /// - public ConnectorType ConnectorType - { - get => _ConnectorType; - } - - /// - /// To choose the last TV format set this value to TVFormat.None - /// In case of NvAPI_DISP_GetDisplayConfig(), this field will indicate the currently applied TV format; - /// if no TV format is applied, this field will have TVFormat.None value. - /// In case of NvAPI_DISP_SetDisplayConfig(), this field should only be set in case of TVs; - /// for other displays this field will be ignored and resolution & refresh rate specified in input will be used to - /// apply the TV format. - /// - public TVFormat TVFormat - { - get => _TVFormat; - } - - /// - /// Ignored if TimingOverride == TimingOverride.Current - /// - public TimingOverride TimingOverride - { - get => _TimingOverride; - } - - /// - /// Scan out timing, valid only if TimingOverride == TimingOverride.Custom - /// The value Timing.PixelClockIn10KHertz is obtained from the EDID. The driver may tweak this value for HDTV, stereo, - /// etc., before reporting it to the OS. - /// - public Timing Timing - { - get => _Timing; - } - - /// - /// Interlaced mode flag, ignored if refreshRate == 0 - /// - public bool IsInterlaced - { - get => _RawReserved.GetBit(0); - private set => _RawReserved = _RawReserved.SetBit(0, value); - } - - /// - /// Declares primary display in clone configuration. This is *NOT* GDI Primary. - /// Only one target can be primary per source. If no primary is specified, the first target will automatically be - /// primary. - /// - public bool IsClonePrimary - { - get => _RawReserved.GetBit(1); - private set => _RawReserved = _RawReserved.SetBit(1, value); - } - - /// - /// Whether on this target Pan and Scan is enabled or has to be enabled. Valid only when the target is part of clone - /// topology. - /// - public bool IsClonePanAndScanTarget - { - get => _RawReserved.GetBit(2); - private set => _RawReserved = _RawReserved.SetBit(2, value); - } - - /// - /// Indicates if virtual mode support is disabled - /// - public bool DisableVirtualModeSupport - { - get => _RawReserved.GetBit(3); - private set => _RawReserved = _RawReserved.SetBit(3, value); - } - - /// - /// Indicates if the target is in preferred unscaled mode - /// - public bool IsPreferredUnscaledTarget - { - get => _RawReserved.GetBit(4); - private set => _RawReserved = _RawReserved.SetBit(4, value); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PathInfoV1.cs b/app/NvAPIWrapper/Native/Display/Structures/PathInfoV1.cs deleted file mode 100644 index ec497422..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PathInfoV1.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds information about a path - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - // ReSharper disable once RedundantExtendsListEntry - public struct PathInfoV1 : IPathInfo, IInitializable, IAllocatable, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _ReservedSourceId; - internal readonly uint _TargetInfoCount; - internal ValueTypeArray _TargetsInfo; - internal ValueTypeReference _SourceModeInfo; - - /// - public uint SourceId - { - get => _ReservedSourceId; - } - - /// - public IEnumerable TargetsInfo - { - get => _TargetsInfo.ToArray((int) _TargetInfoCount)?.Cast() ?? new IPathTargetInfo[0]; - } - - /// - public SourceModeInfo SourceModeInfo - { - get => _SourceModeInfo.ToValueType() ?? default(SourceModeInfo); - } - - /// - /// Creates a new PathInfoV1 - /// - /// Information about path targets - /// Source mode information - /// Source Id, can be zero - public PathInfoV1( - PathTargetInfoV1[] targetsInformation, - SourceModeInfo sourceModeInformation, - uint sourceId = 0) - { - this = typeof(PathInfoV1).Instantiate(); - _TargetInfoCount = (uint) targetsInformation.Length; - _TargetsInfo = ValueTypeArray.FromArray(targetsInformation); - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInformation); - _ReservedSourceId = sourceId; - } - - /// - public bool Equals(PathInfoV1 other) - { - return _TargetInfoCount == other._TargetInfoCount && - _TargetsInfo.Equals(other._TargetsInfo) && - _SourceModeInfo.Equals(other._SourceModeInfo); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PathInfoV1 && Equals((PathInfoV1) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _TargetInfoCount; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ _TargetsInfo.GetHashCode(); - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ _SourceModeInfo.GetHashCode(); - - return hashCode; - } - } - - /// - /// Creates a new PathInfoV1 - /// - /// Information about path targets - /// Source Id, can be zero - public PathInfoV1(PathTargetInfoV1[] targetsInformation, uint sourceId = 0) - { - this = typeof(PathInfoV1).Instantiate(); - _TargetInfoCount = (uint) targetsInformation.Length; - _TargetsInfo = ValueTypeArray.FromArray(targetsInformation); - _SourceModeInfo = ValueTypeReference.Null; - _ReservedSourceId = sourceId; - } - - /// - /// Creates a new PathInfoV1 - /// - /// Source Id, can be zero - public PathInfoV1(uint sourceId) - { - this = typeof(PathInfoV1).Instantiate(); - _TargetInfoCount = 0; - _TargetsInfo = ValueTypeArray.Null; - _SourceModeInfo = ValueTypeReference.Null; - _ReservedSourceId = sourceId; - } - - /// - /// Creates a new PathInfoV1 - /// - /// Source mode information - /// Source Id, can be zero - public PathInfoV1(SourceModeInfo sourceModeInfo, uint sourceId) - { - this = typeof(PathInfoV1).Instantiate(); - _TargetInfoCount = 0; - _TargetsInfo = ValueTypeArray.Null; - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInfo); - _ReservedSourceId = sourceId; - } - - /// - public void Dispose() - { - TargetsInfo.DisposeAll(); - _TargetsInfo.Dispose(); - _SourceModeInfo.Dispose(); - } - - void IAllocatable.Allocate() - { - if (_TargetInfoCount > 0 && _TargetsInfo.IsNull) - { - var targetInfo = typeof(PathTargetInfoV1).Instantiate(); - var targetInfoList = targetInfo.Repeat((int) _TargetInfoCount).AllocateAll(); - _TargetsInfo = ValueTypeArray.FromArray(targetInfoList.ToArray()); - } - - if (_SourceModeInfo.IsNull) - { - var sourceModeInfo = typeof(SourceModeInfo).Instantiate(); - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInfo); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PathInfoV2.cs b/app/NvAPIWrapper/Native/Display/Structures/PathInfoV2.cs deleted file mode 100644 index ed721fe1..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PathInfoV2.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds information about a path - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - // ReSharper disable once RedundantExtendsListEntry - public struct PathInfoV2 : IPathInfo, IInitializable, IAllocatable, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _SourceId; - internal readonly uint _TargetInfoCount; - internal ValueTypeArray _TargetsInfo; - internal ValueTypeReference _SourceModeInfo; - internal readonly uint _RawReserved; - internal ValueTypeReference _OSAdapterLUID; - - /// - public uint SourceId - { - get => _SourceId; - } - - /// - public bool Equals(PathInfoV2 other) - { - return _TargetInfoCount == other._TargetInfoCount && - _TargetsInfo.Equals(other._TargetsInfo) && - _SourceModeInfo.Equals(other._SourceModeInfo) && - _RawReserved == other._RawReserved; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PathInfoV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _TargetInfoCount; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ _TargetsInfo.GetHashCode(); - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ _SourceModeInfo.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _RawReserved; - - return hashCode; - } - } - - /// - public IEnumerable TargetsInfo - { - get => _TargetsInfo.ToArray((int) _TargetInfoCount)?.Cast() ?? new IPathTargetInfo[0]; - } - - /// - public SourceModeInfo SourceModeInfo - { - get => _SourceModeInfo.ToValueType() ?? default(SourceModeInfo); - } - - /// - /// True for non-NVIDIA adapter. - /// - public bool IsNonNVIDIAAdapter - { - get => _RawReserved.GetBit(0); - } - - /// - /// Used by Non-NVIDIA adapter for OS Adapter of LUID - /// - public LUID? OSAdapterLUID - { - get => _OSAdapterLUID.ToValueType(); - } - - /// - /// Creates a new PathInfoV2 - /// - /// Information about path targets - /// Source mode information - /// Source Id, can be zero - public PathInfoV2(PathTargetInfoV2[] targetInformations, SourceModeInfo sourceModeInfo, uint sourceId = 0) - { - this = typeof(PathInfoV2).Instantiate(); - _TargetInfoCount = (uint) targetInformations.Length; - _TargetsInfo = ValueTypeArray.FromArray(targetInformations); - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInfo); - _SourceId = sourceId; - } - - /// - /// Creates a new PathInfoV2 - /// - /// Information about path targets - /// Source Id, can be zero - public PathInfoV2(PathTargetInfoV2[] targetInformations, uint sourceId = 0) - { - this = typeof(PathInfoV2).Instantiate(); - _TargetInfoCount = (uint) targetInformations.Length; - _TargetsInfo = ValueTypeArray.FromArray(targetInformations); - _SourceModeInfo = ValueTypeReference.Null; - _SourceId = sourceId; - } - - - /// - /// Creates a new PathInfoV2 - /// - /// Source Id, can be zero - public PathInfoV2(uint sourceId) - { - this = typeof(PathInfoV2).Instantiate(); - _TargetInfoCount = 0; - _TargetsInfo = ValueTypeArray.Null; - _SourceModeInfo = ValueTypeReference.Null; - _SourceId = sourceId; - } - - /// - /// Creates a new PathInfoV2 - /// - /// Source mode information - /// Source Id, can be zero - public PathInfoV2(SourceModeInfo sourceModeInfo, uint sourceId) - { - this = typeof(PathInfoV2).Instantiate(); - _TargetInfoCount = 0; - _TargetsInfo = ValueTypeArray.Null; - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInfo); - _SourceId = sourceId; - } - - /// - public void Dispose() - { - TargetsInfo.DisposeAll(); - _TargetsInfo.Dispose(); - _SourceModeInfo.Dispose(); - } - - void IAllocatable.Allocate() - { - if (_TargetInfoCount > 0 && _TargetsInfo.IsNull) - { - var targetInfo = typeof(PathTargetInfoV2).Instantiate(); - var targetInfoList = targetInfo.Repeat((int) _TargetInfoCount).AllocateAll(); - _TargetsInfo = ValueTypeArray.FromArray(targetInfoList.ToArray()); - } - - if (_SourceModeInfo.IsNull) - { - var sourceModeInfo = typeof(SourceModeInfo).Instantiate(); - _SourceModeInfo = ValueTypeReference.FromValueType(sourceModeInfo); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV1.cs b/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV1.cs deleted file mode 100644 index 4bdaddbc..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV1.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -// ReSharper disable RedundantExtendsListEntry - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds information about a path's target - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PathTargetInfoV1 : IPathTargetInfo, - IInitializable, - IDisposable, - IAllocatable, - IEquatable, - IEquatable - { - internal readonly uint _DisplayId; - internal ValueTypeReference _Details; - - /// - public override string ToString() - { - return $"PathTargetInfoV2: Display #{_DisplayId}"; - } - - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - public bool Equals(PathTargetInfoV1 other) - { - return _DisplayId == other._DisplayId && _Details.Equals(other._Details); - } - - /// - public bool Equals(PathTargetInfoV2 other) - { - return _DisplayId == other._DisplayId && _Details.Equals(other._Details); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PathTargetInfoV1 && Equals((PathTargetInfoV1) obj); - } - - /// - public override int GetHashCode() - { - unchecked - { - // ReSharper disable once NonReadonlyMemberInGetHashCode - return ((int) _DisplayId * 397) ^ _Details.GetHashCode(); - } - } - - /// - public PathAdvancedTargetInfo? Details - { - get => _Details.ToValueType() ?? default(PathAdvancedTargetInfo); - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - public PathTargetInfoV1(uint displayId) : this() - { - _DisplayId = displayId; - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - /// Extra information - public PathTargetInfoV1(uint displayId, PathAdvancedTargetInfo details) : this(displayId) - { - _Details = ValueTypeReference.FromValueType(details); - } - - /// - public void Dispose() - { - _Details.Dispose(); - } - - void IAllocatable.Allocate() - { - if (_Details.IsNull) - { - var detail = typeof(PathAdvancedTargetInfo).Instantiate(); - _Details = ValueTypeReference.FromValueType(detail); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV2.cs b/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV2.cs deleted file mode 100644 index 00c21ace..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PathTargetInfoV2.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -// ReSharper disable RedundantExtendsListEntry - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds information about a path's target - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PathTargetInfoV2 : IPathTargetInfo, - IInitializable, - IDisposable, - IAllocatable, - IEquatable, - IEquatable - { - internal readonly uint _DisplayId; - internal ValueTypeReference _Details; - internal readonly uint _WindowsCCDTargetId; - - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - public override string ToString() - { - return $"PathTargetInfoV2: Display #{_DisplayId}"; - } - - /// - public PathAdvancedTargetInfo? Details - { - get => _Details.ToValueType(); - } - - /// - /// Windows CCD target ID. Must be present only for non-NVIDIA adapter, for NVIDIA adapter this parameter is ignored. - /// - public uint WindowsCCDTargetId - { - get => _WindowsCCDTargetId; - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - public PathTargetInfoV2(uint displayId) : this() - { - _DisplayId = displayId; - } - - /// - public bool Equals(PathTargetInfoV2 other) - { - return _DisplayId == other._DisplayId && _Details.Equals(other._Details); - } - - /// - public bool Equals(PathTargetInfoV1 other) - { - return _DisplayId == other._DisplayId && _Details.Equals(other._Details); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PathTargetInfoV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _DisplayId; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ _Details.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _WindowsCCDTargetId; - - return hashCode; - } - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - /// Windows CCD target Id - public PathTargetInfoV2(uint displayId, uint windowsCCDTargetId) : this(displayId) - { - _WindowsCCDTargetId = windowsCCDTargetId; - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - /// Extra information - public PathTargetInfoV2(uint displayId, PathAdvancedTargetInfo details) : this(displayId) - { - _Details = ValueTypeReference.FromValueType(details); - } - - /// - /// Creates a new PathTargetInfoV1 - /// - /// Display Id - /// Windows CCD target Id - /// Extra information - public PathTargetInfoV2(uint displayId, uint windowsCCDTargetId, PathAdvancedTargetInfo details) - : this(displayId, windowsCCDTargetId) - { - _Details = ValueTypeReference.FromValueType(details); - } - - - /// - public void Dispose() - { - _Details.Dispose(); - } - - void IAllocatable.Allocate() - { - if (_Details.IsNull) - { - var detail = typeof(PathAdvancedTargetInfo).Instantiate(); - _Details = ValueTypeReference.FromValueType(detail); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/Position.cs b/app/NvAPIWrapper/Native/Display/Structures/Position.cs deleted file mode 100644 index 1d36732f..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/Position.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds a [X,Y] pair as a position on a 2D plane - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct Position : IEquatable - { - internal readonly int _X; - internal readonly int _Y; - - /// - public override string ToString() - { - return $"[{X}, {Y}]"; - } - - /// - public bool Equals(Position other) - { - return _X == other._X && _Y == other._Y; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is Position position && Equals(position); - } - - /// - public override int GetHashCode() - { - unchecked - { - return (_X * 397) ^ _Y; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(Position left, Position right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(Position left, Position right) - { - return !left.Equals(right); - } - - /// - /// Creates a new Position - /// - /// X value - /// Y value - public Position(int x, int y) - { - _X = x; - _Y = y; - } - - /// - /// X value - /// - public int X - { - get => _X; - } - - /// - /// Y value - /// - public int Y - { - get => _Y; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfo.cs b/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfo.cs deleted file mode 100644 index 69efc133..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateDisplayDVCInfo : IInitializable, IDisplayDVCInfo - { - internal StructureVersion _Version; - internal int _CurrentLevel; - internal int _MinimumLevel; - internal int _MaximumLevel; - - /// - public int CurrentLevel - { - get => _CurrentLevel; - } - - /// - public int MinimumLevel - { - get => _MinimumLevel; - } - - /// - int IDisplayDVCInfo.DefaultLevel - { - get => 0; - } - - /// - public int MaximumLevel - { - get => _MaximumLevel; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfoEx.cs b/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfoEx.cs deleted file mode 100644 index cb37c2ef..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayDVCInfoEx.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Display; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateDisplayDVCInfoEx : IInitializable, IDisplayDVCInfo - { - internal StructureVersion _Version; - internal int _CurrentLevel; - internal int _MinimumLevel; - internal int _MaximumLevel; - internal int _DefaultLevel; - - /// - public int CurrentLevel - { - get => _CurrentLevel; - } - - /// - public int MinimumLevel - { - get => _MinimumLevel; - } - - /// - public int MaximumLevel - { - get => _MaximumLevel; - } - - /// - public int DefaultLevel - { - get => _DefaultLevel; - } - - internal PrivateDisplayDVCInfoEx(int currentLevel) - { - this = typeof(PrivateDisplayDVCInfoEx).Instantiate(); - _CurrentLevel = currentLevel; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayHUEInfo.cs b/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayHUEInfo.cs deleted file mode 100644 index 38e2d103..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/PrivateDisplayHUEInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds the current and the default HUE information - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateDisplayHUEInfo : IInitializable - { - internal StructureVersion _Version; - internal int _CurrentAngle; - internal int _DefaultAngle; - - /// - /// Gets or sets the current HUE offset angle [0-359] - /// - public int CurrentAngle - { - get => _CurrentAngle; - } - - /// - /// Gets or sets the default HUE offset angle [0-359] - /// - public int DefaultAngle - { - get => _DefaultAngle; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/Resolution.cs b/app/NvAPIWrapper/Native/Display/Structures/Resolution.cs deleted file mode 100644 index ad34a579..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/Resolution.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds a [Width, Height] pair as the resolution of a display device, as well as a color format - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct Resolution : IEquatable - { - internal readonly uint _Width; - internal readonly uint _Height; - internal readonly uint _ColorDepth; - - /// - /// Creates a new Resolution - /// - /// Display resolution width - /// Display resolution height - /// Display color depth - public Resolution(int width, int height, int colorDepth) - { - _Width = (uint) width; - _Height = (uint) height; - _ColorDepth = (uint) colorDepth; - } - - /// - public bool Equals(Resolution other) - { - return _Width == other._Width && _Height == other._Height && _ColorDepth == other._ColorDepth; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is Resolution resolution && Equals(resolution); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Width; - hashCode = (hashCode * 397) ^ (int) _Height; - hashCode = (hashCode * 397) ^ (int) _ColorDepth; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(Resolution left, Resolution right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(Resolution left, Resolution right) - { - return !left.Equals(right); - } - - /// - public override string ToString() - { - return $"({Width}, {Height}) @ {ColorDepth}bpp"; - } - - /// - /// Display resolution width - /// - public int Width - { - get => (int) _Width; - } - - /// - /// Display resolution height - /// - public int Height - { - get => (int) _Height; - } - - /// - /// Display color depth - /// - public int ColorDepth - { - get => (int) _ColorDepth; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutInformationV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutInformationV1.cs deleted file mode 100644 index b1cf8b37..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutInformationV1.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding the scan-out configurations - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ScanOutInformationV1 : IInitializable - { - internal StructureVersion _Version; - internal Rectangle _SourceDesktopRectangle; - internal Rectangle _SourceViewPortRectangle; - internal Rectangle _TargetViewPortRectangle; - internal uint _TargetDisplayWidth; - internal uint _TargetDisplayHeight; - internal uint _CloneImportance; - internal Rotate _SourceToTargetRotation; - - /// - /// Gets the operating system display device rectangle in desktop coordinates displayId is scanning out from. - /// - public Rectangle SourceDesktopRectangle - { - get => _SourceDesktopRectangle; - } - - /// - /// Gets the area inside the SourceDesktopRectangle which is scanned out to the display. - /// - public Rectangle SourceViewPortRectangle - { - get => _SourceViewPortRectangle; - } - - /// - /// Gets the area inside the rectangle described by targetDisplayWidth/Height SourceViewPortRectangle is scanned out - /// to. - /// - public Rectangle TargetViewPortRectangle - { - get => _TargetViewPortRectangle; - } - - /// - /// Gets the horizontal size of the active resolution scanned out to the display. - /// - public uint TargetDisplayWidth - { - get => _TargetDisplayWidth; - } - - /// - /// Gets the vertical size of the active resolution scanned out to the display. - /// - public uint TargetDisplayHeight - { - get => _TargetDisplayHeight; - } - - /// - /// Gets the clone importance assigned to the target if the target is a cloned view of the SourceDesktopRectangle - /// (0:primary,1 secondary,...). - /// - public uint CloneImportance - { - get => _CloneImportance; - } - - /// - /// Gets the rotation performed between the SourceViewPortRectangle and the TargetViewPortRectangle. - /// - public Rotate SourceToTargetRotation - { - get => _SourceToTargetRotation; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityStateV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityStateV1.cs deleted file mode 100644 index bb5ef734..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityStateV1.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding the scan-out intensity state - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ScanOutIntensityStateV1 : IInitializable - { - internal StructureVersion _Version; - internal uint _IsEnabled; - - /// - /// Gets a boolean value indicating if the scan out intensity is enabled or not - /// - public bool IsEnabled - { - get => _IsEnabled > 0; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV1.cs deleted file mode 100644 index cba00931..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV1.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ScanOutIntensityV1 : IDisposable, IInitializable, IScanOutIntensity - { - internal StructureVersion _Version; - internal uint _Width; - internal uint _Height; - internal IntPtr _BlendingTexture; - - /// - /// Creates a new instance of . - /// - /// The width of the input texture. - /// The height of the input texture - /// The array of floating values building an intensity RGB texture. - public ScanOutIntensityV1(uint width, uint height, float[] blendingTexture) - { - if (blendingTexture?.Length != width * height * 3) - { - throw new ArgumentOutOfRangeException(nameof(blendingTexture)); - } - - this = typeof(ScanOutIntensityV1).Instantiate(); - _Width = width; - _Height = height; - _BlendingTexture = Marshal.AllocHGlobal((int) (width * height * 3 * sizeof(float))); - - Marshal.Copy(blendingTexture, 0, _BlendingTexture, blendingTexture.Length); - } - - /// - public uint Width - { - get => _Width; - } - - /// - public uint Height - { - get => _Height; - } - - /// - public float[] BlendingTexture - { - get - { - var floats = new float[_Width * _Height * 3]; - Marshal.Copy(_BlendingTexture, floats, 0, floats.Length); - - return floats; - } - } - - /// - public void Dispose() - { - Marshal.FreeHGlobal(_BlendingTexture); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV2.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV2.cs deleted file mode 100644 index 1bc8ffd9..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutIntensityV2.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct ScanOutIntensityV2 : IDisposable, IInitializable, IScanOutIntensity - { - internal StructureVersion _Version; - internal uint _Width; - internal uint _Height; - internal IntPtr _BlendingTexture; - internal IntPtr _OffsetTexture; - internal uint _OffsetTextureChannels; - - /// - /// Creates a new instance of . - /// - /// The width of the input texture. - /// The height of the input texture - /// The array of floating values building an intensity RGB texture - /// The number of channels per pixel in the offset texture - /// The array of floating values building an offset texture - // ReSharper disable once TooManyDependencies - public ScanOutIntensityV2( - uint width, - uint height, - float[] blendingTexture, - uint offsetTextureChannels, - float[] offsetTexture) - { - if (blendingTexture?.Length != width * height * 3) - { - throw new ArgumentOutOfRangeException(nameof(blendingTexture)); - } - - if (offsetTexture?.Length != width * height * offsetTextureChannels) - { - throw new ArgumentOutOfRangeException(nameof(offsetTexture)); - } - - this = typeof(ScanOutIntensityV2).Instantiate(); - _Width = width; - _Height = height; - _BlendingTexture = Marshal.AllocHGlobal((int) (width * height * 3 * sizeof(float))); - Marshal.Copy(blendingTexture, 0, _BlendingTexture, blendingTexture.Length); - - _OffsetTextureChannels = offsetTextureChannels; - _OffsetTexture = Marshal.AllocHGlobal((int) (width * height * offsetTextureChannels * sizeof(float))); - Marshal.Copy(offsetTexture, 0, _OffsetTexture, offsetTexture.Length); - } - - /// - public uint Width - { - get => _Width; - } - - /// - public uint Height - { - get => _Height; - } - - /// - /// Gets the number of channels per pixel in the offset texture - /// - public uint OffsetTextureChannels - { - get => _OffsetTextureChannels; - } - - /// - public float[] BlendingTexture - { - get - { - var floats = new float[_Width * _Height * 3]; - Marshal.Copy(_BlendingTexture, floats, 0, floats.Length); - - return floats; - } - } - - /// - /// Gets the array of floating values building an offset texture - /// - public float[] OffsetTexture - { - get - { - var floats = new float[_Width * _Height * _OffsetTextureChannels]; - Marshal.Copy(_OffsetTexture, floats, 0, floats.Length); - - return floats; - } - } - - /// - public void Dispose() - { - Marshal.FreeHGlobal(_BlendingTexture); - Marshal.FreeHGlobal(_OffsetTexture); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingStateV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingStateV1.cs deleted file mode 100644 index a09fa23b..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingStateV1.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding the scan-out warping state - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ScanOutWarpingStateV1 : IInitializable - { - internal StructureVersion _Version; - internal uint _IsEnabled; - - /// - /// Gets a boolean value indicating if the scan out warping is enabled or not - /// - public bool IsEnabled - { - get => _IsEnabled > 0; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingV1.cs b/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingV1.cs deleted file mode 100644 index a2e1d60a..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ScanOutWarpingV1.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding the scan-out warping data - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ScanOutWarpingV1 : IDisposable, IInitializable - { - internal StructureVersion _Version; - internal IntPtr _Vertices; - internal WarpingVerticeFormat _VertexFormat; - internal uint _NumberOfVertices; - internal IntPtr _TextureRectangle; - - /// - /// Creates a new instance of . - /// - /// The format of the input vertices. - /// The array of floating values containing the warping vertices. - /// The rectangle in desktop coordinates describing the source area for the warping. - public ScanOutWarpingV1(WarpingVerticeFormat vertexFormat, float[] vertices, Rectangle textureRectangle) - { - if (vertices.Length % 6 != 0) - { - throw new ArgumentOutOfRangeException(nameof(vertices)); - } - - this = typeof(ScanOutWarpingV1).Instantiate(); - _VertexFormat = vertexFormat; - _NumberOfVertices = (uint) (vertices.Length / 6); - _Vertices = Marshal.AllocHGlobal(vertices.Length * sizeof(float)); - Marshal.Copy(vertices, 0, _Vertices, vertices.Length); - - _TextureRectangle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Rectangle))); - Marshal.StructureToPtr(textureRectangle, _TextureRectangle, true); - } - - /// - /// Gets the format of the input vertices - /// - public WarpingVerticeFormat VertexFormat - { - get => _VertexFormat; - } - - /// - /// Gets the rectangle in desktop coordinates describing the source area for the warping - /// - public Rectangle TextureRectangle - { - get => (Rectangle)Marshal.PtrToStructure(_TextureRectangle, typeof(Rectangle)); - } - - /// - /// Gets the array of floating values containing the warping vertices - /// - public float[] Vertices - { - get - { - var floats = new float[_NumberOfVertices * 6]; - Marshal.Copy(_Vertices, floats, 0, floats.Length); - - return floats; - } - } - - /// - public void Dispose() - { - Marshal.FreeHGlobal(_Vertices); - Marshal.FreeHGlobal(_TextureRectangle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/SourceModeInfo.cs b/app/NvAPIWrapper/Native/Display/Structures/SourceModeInfo.cs deleted file mode 100644 index 132777b6..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/SourceModeInfo.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds information about a source mode - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct SourceModeInfo : IEquatable - { - internal readonly Resolution _Resolution; - internal readonly ColorFormat _ColorFormat; - internal readonly Position _Position; - internal readonly SpanningOrientation _SpanningOrientation; - internal uint _RawReserved; - - /// - /// Creates a new SourceModeInfo - /// - /// Source resolution - /// Must be Format.Unknown - /// Source position - /// Spanning orientation for XP - /// true if this source represents the GDI primary display, otherwise false - /// true if this source represents the SLI focus display, otherwise false - public SourceModeInfo( - Resolution resolution, - ColorFormat colorFormat, - Position position = default(Position), - SpanningOrientation spanningOrientation = SpanningOrientation.None, - bool isGDIPrimary = false, - bool isSLIFocus = false) : this() - { - _Resolution = resolution; - _ColorFormat = colorFormat; - _Position = position; - _SpanningOrientation = spanningOrientation; - IsGDIPrimary = isGDIPrimary; - IsSLIFocus = isSLIFocus; - } - - /// - public bool Equals(SourceModeInfo other) - { - return _Resolution.Equals(other._Resolution) && - _ColorFormat == other._ColorFormat && - _Position.Equals(other._Position) && - _SpanningOrientation == other._SpanningOrientation && - _RawReserved == other._RawReserved; - } - - /// - public override bool Equals(object obj) - { - if (obj == null) - { - return false; - } - - return obj is SourceModeInfo info && Equals(info); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = _Resolution.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _ColorFormat; - hashCode = (hashCode * 397) ^ _Position.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _SpanningOrientation; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ (int) _RawReserved; - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"{Resolution} @ {Position} - {ColorFormat}"; - } - - /// - /// Holds the source resolution - /// - public Resolution Resolution - { - get => _Resolution; - } - - /// - /// Ignored at present, must be Format.Unknown - /// - public ColorFormat ColorFormat - { - get => _ColorFormat; - } - - /// - /// Is all positions are 0 or invalid, displays will be automatically positioned from left to right with GDI Primary at - /// 0,0, and all other displays in the order of the path array. - /// - public Position Position - { - get => _Position; - } - - /// - /// Spanning is only supported on XP - /// - public SpanningOrientation SpanningOrientation - { - get => _SpanningOrientation; - } - - /// - /// Indicates if the path is for the primary GDI display - /// - public bool IsGDIPrimary - { - get => _RawReserved.GetBit(0); - private set => _RawReserved = _RawReserved.SetBit(0, value); - } - - /// - /// Indicates if the path is for the SLI focus display - /// - public bool IsSLIFocus - { - get => _RawReserved.GetBit(1); - private set => _RawReserved = _RawReserved.SetBit(1, value); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/Timing.cs b/app/NvAPIWrapper/Native/Display/Structures/Timing.cs deleted file mode 100644 index e863f3d0..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/Timing.cs +++ /dev/null @@ -1,382 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds VESA scan out timing parameters - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct Timing : IEquatable - { - internal readonly ushort _HorizontalVisible; - internal readonly ushort _HorizontalBorder; - internal readonly ushort _HorizontalFrontPorch; - internal readonly ushort _HorizontalSyncWidth; - internal readonly ushort _HorizontalTotal; - internal readonly TimingHorizontalSyncPolarity _HorizontalSyncPolarity; - internal readonly ushort _VerticalVisible; - internal readonly ushort _VerticalBorder; - internal readonly ushort _VerticalFrontPorch; - internal readonly ushort _VerticalSyncWidth; - internal readonly ushort _VerticalTotal; - internal readonly TimingVerticalSyncPolarity _VerticalSyncPolarity; - internal readonly TimingScanMode _ScanMode; - internal readonly uint _PixelClockIn10KHertz; - internal readonly TimingExtra _Extra; - - /// - /// Creates an instance of structure. - /// - /// The horizontal visible pixels - /// The vertical visible pixels - /// The horizontal border pixels - /// The vertical border pixels - /// The horizontal front porch pixels - /// The vertical front porch pixels - /// The horizontal sync width pixels - /// The vertical sync width pixels - /// The horizontal total pixels - /// The vertical total pixels - /// The horizontal sync polarity - /// The vertical sync polarity - /// The scan mode - /// The extra timing information - public Timing( - ushort horizontalVisible, - ushort verticalVisible, - ushort horizontalBorder, - ushort verticalBorder, - ushort horizontalFrontPorch, - ushort verticalFrontPorch, - ushort horizontalSyncWidth, - ushort verticalSyncWidth, - ushort horizontalTotal, - ushort verticalTotal, - TimingHorizontalSyncPolarity horizontalPolarity, - TimingVerticalSyncPolarity verticalPolarity, - TimingScanMode scanMode, - TimingExtra extra - ) - { - this = typeof(Timing).Instantiate(); - - _HorizontalVisible = horizontalVisible; - _HorizontalBorder = horizontalBorder; - _HorizontalFrontPorch = horizontalFrontPorch; - _HorizontalSyncWidth = horizontalSyncWidth; - _HorizontalTotal = horizontalTotal; - _HorizontalSyncPolarity = horizontalPolarity; - - _VerticalVisible = verticalVisible; - _VerticalBorder = verticalBorder; - _VerticalFrontPorch = verticalFrontPorch; - _VerticalSyncWidth = verticalSyncWidth; - _VerticalTotal = verticalTotal; - _VerticalSyncPolarity = verticalPolarity; - - _ScanMode = scanMode; - _PixelClockIn10KHertz = - (uint) (horizontalTotal * verticalTotal * (extra.FrequencyInMillihertz / 1000d) / 10000); - - _Extra = extra; - } - - /// - /// Creates an instance of structure. - /// - /// The horizontal visible pixels - /// The vertical visible pixels - /// The horizontal border pixels - /// The vertical border pixels - /// The horizontal front porch pixels - /// The vertical front porch pixels - /// The horizontal sync width pixels - /// The vertical sync width pixels - /// The horizontal total pixels - /// The vertical total pixels - /// The horizontal sync polarity - /// The vertical sync polarity - /// The scan mode - /// The frequency in hertz - /// The number of identical horizontal pixels that are repeated; 1 = no repetition - public Timing( - ushort horizontalVisible, - ushort verticalVisible, - ushort horizontalBorder, - ushort verticalBorder, - ushort horizontalFrontPorch, - ushort verticalFrontPorch, - ushort horizontalSyncWidth, - ushort verticalSyncWidth, - ushort horizontalTotal, - ushort verticalTotal, - TimingHorizontalSyncPolarity horizontalPolarity, - TimingVerticalSyncPolarity verticalPolarity, - TimingScanMode scanMode, - double refreshRateFrequencyInHz, - ushort horizontalPixelRepetition = 1 - ) : this( - horizontalVisible, verticalVisible, horizontalBorder, - verticalBorder, horizontalFrontPorch, verticalFrontPorch, - horizontalSyncWidth, verticalSyncWidth, horizontalTotal, - verticalTotal, horizontalPolarity, verticalPolarity, scanMode, - new TimingExtra( - refreshRateFrequencyInHz, - $"CUST:{horizontalVisible}x{verticalVisible}x{refreshRateFrequencyInHz:F3}Hz", - 0, - 0, - horizontalPixelRepetition - ) - ) - { - } - - /// - public bool Equals(Timing other) - { - return _HorizontalVisible == other._HorizontalVisible && - _HorizontalBorder == other._HorizontalBorder && - _HorizontalFrontPorch == other._HorizontalFrontPorch && - _HorizontalSyncWidth == other._HorizontalSyncWidth && - _HorizontalTotal == other._HorizontalTotal && - _HorizontalSyncPolarity == other._HorizontalSyncPolarity && - _VerticalVisible == other._VerticalVisible && - _VerticalBorder == other._VerticalBorder && - _VerticalFrontPorch == other._VerticalFrontPorch && - _VerticalSyncWidth == other._VerticalSyncWidth && - _VerticalTotal == other._VerticalTotal && - _VerticalSyncPolarity == other._VerticalSyncPolarity && - _ScanMode == other._ScanMode && - _PixelClockIn10KHertz == other._PixelClockIn10KHertz && - _Extra.Equals(other._Extra); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is Timing timing && Equals(timing); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = _HorizontalVisible.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalBorder.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalFrontPorch.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalSyncWidth.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalTotal.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _HorizontalSyncPolarity; - hashCode = (hashCode * 397) ^ _VerticalVisible.GetHashCode(); - hashCode = (hashCode * 397) ^ _VerticalBorder.GetHashCode(); - hashCode = (hashCode * 397) ^ _VerticalFrontPorch.GetHashCode(); - hashCode = (hashCode * 397) ^ _VerticalSyncWidth.GetHashCode(); - hashCode = (hashCode * 397) ^ _VerticalTotal.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _VerticalSyncPolarity; - hashCode = (hashCode * 397) ^ (int) _ScanMode; - hashCode = (hashCode * 397) ^ (int) _PixelClockIn10KHertz; - hashCode = (hashCode * 397) ^ _Extra.GetHashCode(); - - return hashCode; - } - } - - /// - /// Checks two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// Returns a boolean value indicating if the two instances are equal; otherwise false - public static bool operator ==(Timing left, Timing right) - { - return left.Equals(right); - } - - /// - /// Checks two instance of for in equality. - /// - /// The first instance. - /// The second instance. - /// Returns a boolean value indicating if the two instances are not equal; otherwise false - public static bool operator !=(Timing left, Timing right) - { - return !(left == right); - } - - /// - /// Get the horizontal visible pixels - /// - public int HorizontalVisible - { - get => _HorizontalVisible; - } - - /// - /// Get the horizontal border pixels - /// - public int HorizontalBorder - { - get => _HorizontalBorder; - } - - /// - /// Get the horizontal front porch pixels - /// - public int HorizontalFrontPorch - { - get => _HorizontalFrontPorch; - } - - /// - /// Get the horizontal sync width pixels - /// - public int HorizontalSyncWidth - { - get => _HorizontalSyncWidth; - } - - /// - /// Get the horizontal total pixels - /// - public int HorizontalTotal - { - get => _HorizontalTotal; - } - - /// - /// Get the horizontal sync polarity - /// - public TimingHorizontalSyncPolarity HorizontalSyncPolarity - { - get => _HorizontalSyncPolarity; - } - - /// - /// Get the vertical visible pixels - /// - public int VerticalVisible - { - get => _VerticalVisible; - } - - /// - /// Get the vertical border pixels - /// - public int VerticalBorder - { - get => _VerticalBorder; - } - - /// - /// Get the vertical front porch pixels - /// - public int VerticalFrontPorch - { - get => _VerticalFrontPorch; - } - - /// - /// Get the vertical sync width pixels - /// - public int VerticalSyncWidth - { - get => _VerticalSyncWidth; - } - - /// - /// Get the vertical total pixels - /// - public int VerticalTotal - { - get => _VerticalTotal; - } - - /// - /// Get the vertical sync polarity - /// - public TimingVerticalSyncPolarity VerticalSyncPolarity - { - get => _VerticalSyncPolarity; - } - - /// - /// Get the scan mode - /// - public TimingScanMode ScanMode - { - get => _ScanMode; - } - - /// - /// Get the pixel clock in 10 kHz - /// - public int PixelClockIn10KHertz - { - get => (int) _PixelClockIn10KHertz; - } - - /// - /// Get the other timing related extras - /// - public TimingExtra Extra - { - get => _Extra; - } - - /// - /// Gets the horizontal active pixels - /// - public int HorizontalActive - { - get => HorizontalVisible + HorizontalBorder; - } - - /// - /// Gets the vertical active pixels - /// - public int VerticalActive - { - get => VerticalVisible + VerticalBorder; - } - - /// - /// Gets the horizontal back porch pixels - /// - public int HorizontalBackPorch - { - get => HorizontalBlanking - (HorizontalFrontPorch + HorizontalSyncWidth); - } - - /// - /// Gets the horizontal blanking pixels - /// - public int HorizontalBlanking - { - get => HorizontalTotal - (HorizontalActive + HorizontalBorder); - } - - /// - /// Gets vertical back porch pixels - /// - public int VerticalBackPorch - { - get => VerticalBlanking - (VerticalFrontPorch + VerticalSyncWidth); - } - - /// - /// Gets the vertical blanking pixels - /// - public int VerticalBlanking - { - get => VerticalTotal - (VerticalActive + VerticalBorder); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/TimingExtra.cs b/app/NvAPIWrapper/Native/Display/Structures/TimingExtra.cs deleted file mode 100644 index 6c218b2e..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/TimingExtra.cs +++ /dev/null @@ -1,215 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Holds NVIDIA-specific timing extras - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct TimingExtra : IInitializable, IEquatable - { - internal readonly uint _HardwareFlags; - internal readonly ushort _RefreshRate; - internal readonly uint _FrequencyInMillihertz; - internal readonly ushort _VerticalAspect; - internal readonly ushort _HorizontalAspect; - internal readonly ushort _HorizontalPixelRepetition; - internal readonly uint _Standard; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 40)] - internal string _Name; - - /// - /// Creates a new instance of structure. - /// - /// The timing frequency in hertz - /// The timing source name - /// The display horizontal aspect - /// The display vertical aspect - /// The number of identical horizontal pixels that are repeated; 1 = no repetition - /// The NVIDIA hardware-based enhancement, such as double-scan. - public TimingExtra( - double frequencyInHertz, - string name, - ushort horizontalAspect = 0, - ushort verticalAspect = 0, - ushort horizontalPixelRepetition = 1, - uint hardwareFlags = 0 - ) : this( - (uint) (frequencyInHertz * 1000d), - (ushort) frequencyInHertz, - name, - horizontalAspect, - verticalAspect, - horizontalPixelRepetition, - hardwareFlags - ) - { - } - - /// - /// Creates a new instance of structure. - /// - /// The timing frequency in millihertz - /// The refresh rate - /// The timing source name - /// The display horizontal aspect - /// The display vertical aspect - /// The number of identical horizontal pixels that are repeated; 1 = no repetition - /// The NVIDIA hardware-based enhancement, such as double-scan. - public TimingExtra( - uint frequencyInMillihertz, - ushort refreshRate, - string name, - ushort horizontalAspect = 0, - ushort verticalAspect = 0, - ushort horizontalPixelRepetition = 1, - uint hardwareFlags = 0 - ) - { - this = typeof(TimingExtra).Instantiate(); - _FrequencyInMillihertz = frequencyInMillihertz; - _RefreshRate = refreshRate; - _HorizontalAspect = horizontalAspect; - _VerticalAspect = verticalAspect; - _HorizontalPixelRepetition = horizontalPixelRepetition; - _HardwareFlags = hardwareFlags; - _Name = name?.Length > 40 ? name.Substring(0, 40) : name ?? ""; - } - - /// - public bool Equals(TimingExtra other) - { - return _HardwareFlags == other._HardwareFlags && - _RefreshRate == other._RefreshRate && - _FrequencyInMillihertz == other._FrequencyInMillihertz && - _VerticalAspect == other._VerticalAspect && - _HorizontalAspect == other._HorizontalAspect && - _HorizontalPixelRepetition == other._HorizontalPixelRepetition && - _Standard == other._Standard; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is TimingExtra extra && Equals(extra); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _HardwareFlags; - hashCode = (hashCode * 397) ^ _RefreshRate.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _FrequencyInMillihertz; - hashCode = (hashCode * 397) ^ _VerticalAspect.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalAspect.GetHashCode(); - hashCode = (hashCode * 397) ^ _HorizontalPixelRepetition.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _Standard; - - return hashCode; - } - } - - /// - /// Gets the NVIDIA hardware-based enhancement, such as double-scan. - /// - public uint HardwareFlags - { - get => _HardwareFlags; - } - - /// - /// Gets the logical refresh rate to present - /// - public int RefreshRate - { - get => _RefreshRate; - } - - /// - /// Gets the physical vertical refresh rate in 0.001Hz - /// - public int FrequencyInMillihertz - { - get => (int) _FrequencyInMillihertz; - } - - /// - /// Gets the display vertical aspect - /// - public int VerticalAspect - { - get => _VerticalAspect; - } - - /// - /// Gets the display horizontal aspect - /// - public int HorizontalAspect - { - get => _HorizontalAspect; - } - - /// - /// Gets the bit-wise pixel repetition factor: 0x1:no pixel repetition; 0x2:each pixel repeats twice horizontally,.. - /// - public int PixelRepetition - { - get => _HorizontalPixelRepetition; - } - - /// - /// Gets the timing standard - /// - public uint Standard - { - get => _Standard; - } - - /// - /// Gets the timing name - /// - public string Name - { - get => _Name; - } - - /// - public override string ToString() - { - return Name; - } - - /// - /// Checks two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// Returns a boolean value indicating if the two instances are equal; otherwise false - public static bool operator ==(TimingExtra left, TimingExtra right) - { - return left.Equals(right); - } - - /// - /// Checks two instance of for equality. - /// - /// The first instance. - /// The second instance. - /// Returns a boolean value indicating if the two instances are equal; otherwise false - public static bool operator !=(TimingExtra left, TimingExtra right) - { - return !(left == right); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/TimingInput.cs b/app/NvAPIWrapper/Native/Display/Structures/TimingInput.cs deleted file mode 100644 index 33030390..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/TimingInput.cs +++ /dev/null @@ -1,253 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains the information required for calculating timing for a particular display - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct TimingInput : IInitializable - { - [StructLayout(LayoutKind.Explicit, Pack = 8, Size = 12)] - internal struct TimingFlag - { - [FieldOffset(0)] internal ushort _Flags; - [FieldOffset(4)] internal byte _TVFormatCEAIdPSFormatId; - [FieldOffset(8)] internal byte _Scaling; - - public bool IsInterlaced - { - get => _Flags.GetBit(0); - set => _Flags = _Flags.SetBit(0, value); - } - - public TVFormat TVFormat - { - get => (TVFormat) _TVFormatCEAIdPSFormatId; - set => _TVFormatCEAIdPSFormatId = (byte) value; - } - - public byte CEAId - { - get => _TVFormatCEAIdPSFormatId; - set => _TVFormatCEAIdPSFormatId = value; - } - - public byte PredefinedPSFormatId - { - get => _TVFormatCEAIdPSFormatId; - set => _TVFormatCEAIdPSFormatId = value; - } - - public byte Scaling - { - get => _Scaling; - set => _Scaling = value; - } - - public TimingFlag(bool isInterlaced, byte scaling) : this() - { - IsInterlaced = isInterlaced; - Scaling = scaling; - } - - public TimingFlag(bool isInterlaced, byte scaling, TVFormat tvFormat) : this(isInterlaced, scaling) - { - TVFormat = tvFormat; - } - - public TimingFlag(bool isInterlaced, byte scaling, byte ceaIdOrPredefinedPSFormatId) : this(isInterlaced, - scaling) - { - _TVFormatCEAIdPSFormatId = ceaIdOrPredefinedPSFormatId; - } - } - - internal StructureVersion _Version; - internal uint _Width; - internal uint _Height; - internal float _RefreshRate; - internal TimingFlag _Flags; - internal TimingOverride _TimingType; - - /// - /// Gets the visible horizontal size - /// - public uint Width - { - get => _Width; - } - - /// - /// Gets the visible vertical size - /// - public uint Height - { - get => _Height; - } - - /// - /// Gets the timing refresh rate - /// - public float RefreshRate - { - get => _RefreshRate; - } - - /// - /// Gets a boolean value indicating if the requested timing is an interlaced timing - /// - public bool IsInterlaced - { - get => _Flags.IsInterlaced; - } - - /// - /// Gets the preferred scaling - /// - public byte Scaling - { - get => _Flags.Scaling; - } - - /// - /// Gets timing type (formula) to use for calculating the timing - /// - public TimingOverride TimingType - { - get => _TimingType; - } - - /// - /// Creates an instance of the TimingInput - /// - /// The preferred visible horizontal size - /// The preferred visible vertical size - /// The preferred timing refresh rate - /// The preferred formula to be used for timing calculation - /// A boolean value indicating if the preferred timing is interlaced - /// The preferred scaling factor - public TimingInput( - uint width, - uint height, - float refreshRate, - TimingOverride timingType, - bool isInterlaced = false, - byte scaling = 0 - ) - { - this = typeof(TimingInput).Instantiate(); - _Width = width; - _Height = height; - _RefreshRate = refreshRate; - _TimingType = timingType; - _Flags = new TimingFlag(isInterlaced, scaling); - } - - /// - /// Creates an instance of the TimingInput - /// - /// The preferred analog TV format - /// A boolean value indicating if the preferred timing is interlaced - /// The preferred scaling factor - public TimingInput(TVFormat tvFormat, bool isInterlaced = false, byte scaling = 0) - : this(0, 0, 0, TimingOverride.AnalogTV, isInterlaced, scaling) - { - _Flags = new TimingFlag(isInterlaced, scaling, tvFormat); - } - - /// - /// Creates an instance of the TimingInput - /// - /// - /// The CEA id or the predefined PsF format id depending on the value of other - /// arguments - /// - /// - /// The preferred formula to be used for timing calculation, valid values for this overload are - /// and . - /// - /// A boolean value indicating if the preferred timing is interlaced - /// The preferred scaling factor - public TimingInput( - byte ceaIdOrPredefinedPSFormatId, - TimingOverride timingType, - bool isInterlaced = false, - byte scaling = 0 - ) - : this(0, 0, 0, timingType, isInterlaced, scaling) - { - if (timingType != TimingOverride.EIA861 && timingType != TimingOverride.Predefined) - { - throw new ArgumentException("Invalid timing type passed.", nameof(timingType)); - } - - _Flags = new TimingFlag(isInterlaced, scaling, ceaIdOrPredefinedPSFormatId); - } - - /// - /// Creates an instance of the TimingInput - /// - /// - /// The preferred formula to be used for timing calculation. - /// - public TimingInput(TimingOverride timingType) - : this(0, 0, 0, timingType) - { - } - - /// - /// Gets the analog TV actual HD/SDTV format - /// - public TVFormat? TVFormat - { - get - { - if (Width == 0 && Height == 0 && Math.Abs(RefreshRate) < 0.01 && TimingType == TimingOverride.AnalogTV) - { - return _Flags.TVFormat; - } - - return null; - } - } - - /// - /// Gets the EIA/CEA 861B/D predefined short timing descriptor id - /// - public byte? CEAId - { - get - { - if (Width == 0 && Height == 0 && Math.Abs(RefreshRate) < 0.01 && TimingType == TimingOverride.EIA861) - { - return _Flags.CEAId; - } - - return null; - } - } - - /// - /// Gets the Nvidia predefined PsF format id - /// - public byte? PredefinedPSFormatId - { - get - { - if (TimingType == TimingOverride.Predefined) - { - return _Flags.PredefinedPSFormatId; - } - - return null; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/UnAttachedDisplayHandle.cs b/app/NvAPIWrapper/Native/Display/Structures/UnAttachedDisplayHandle.cs deleted file mode 100644 index 528e706b..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/UnAttachedDisplayHandle.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// UnAttachedDisplayHandle is a one-to-one map to the GDI handle of an unattached display. - /// - [StructLayout(LayoutKind.Sequential)] - public struct UnAttachedDisplayHandle : IHandle, IEquatable - { - internal readonly IntPtr _MemoryAddress; - - /// - public bool Equals(UnAttachedDisplayHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is UnAttachedDisplayHandle && Equals((UnAttachedDisplayHandle) obj); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - /// - public override string ToString() - { - return $"UnAttachedDisplayHandle #{MemoryAddress.ToInt64()}"; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(UnAttachedDisplayHandle left, UnAttachedDisplayHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(UnAttachedDisplayHandle left, UnAttachedDisplayHandle right) - { - return !left.Equals(right); - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/Structures/ViewPortF.cs b/app/NvAPIWrapper/Native/Display/Structures/ViewPortF.cs deleted file mode 100644 index b01d18ea..00000000 --- a/app/NvAPIWrapper/Native/Display/Structures/ViewPortF.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Drawing; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Hold information about the screen view port rectangle - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ViewPortF - { - internal float _X; - internal float _Y; - internal float _Width; - internal float _Height; - - /// - /// Gets the x-coordinate of the viewport top-left point - /// - public float X - { - get => _X; - } - - /// - /// Gets the y-coordinate of the viewport top-left point - /// - public float Y - { - get => _Y; - } - - /// - /// Gets the width of the viewport. - /// - public float Width - { - get => _Width; - } - - /// - /// Gets the height of the viewport. - /// - public float Height - { - get => _Height; - } - - /// - /// Creates an instance of ViewPortF - /// - /// The x-coordinate of the viewport top-left point - /// The y-coordinate of the viewport top-left point - /// The width of the viewport. - /// The height of the viewport. - public ViewPortF(float x, float y, float width, float height) - { - _X = x; - _Y = y; - _Width = width; - _Height = height; - } - - /// - /// Creates an instance of - /// - /// The rectangle to take view port information from. - public ViewPortF(RectangleF rect) : this(rect.X, rect.Y, rect.Width, rect.Height) - { - } - - /// - /// Return an instance of representing this view port. - /// - /// - public RectangleF ToRectangle() - { - return new RectangleF(X, Y, Width, Height); - } - - /// - public override string ToString() - { - return $"({Width:F1}, {Height:F1}) @ ({X:F1}, {Y:F1})"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TVFormat.cs b/app/NvAPIWrapper/Native/Display/TVFormat.cs deleted file mode 100644 index 1571d412..00000000 --- a/app/NvAPIWrapper/Native/Display/TVFormat.cs +++ /dev/null @@ -1,219 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Possible TV formats - /// - public enum TVFormat : uint - { - /// - /// Display is not a TV - /// - None = 0, - - /// - /// Standard definition NTSC M signal - /// - // ReSharper disable once InconsistentNaming - SD_NTSCM = 0x00000001, - - /// - /// Standard definition NTSC J signal - /// - // ReSharper disable once InconsistentNaming - SD_NTSCJ = 0x00000002, - - /// - /// Standard definition PAL M signal - /// - // ReSharper disable once InconsistentNaming - SD_PALM = 0x00000004, - - /// - /// Standard definition PAL DFGH signal - /// - // ReSharper disable once InconsistentNaming - SD_PALBDGH = 0x00000008, - - /// - /// Standard definition PAL N signal - /// - // ReSharper disable once InconsistentNaming - SD_PAL_N = 0x00000010, - - /// - /// Standard definition PAL NC signal - /// - // ReSharper disable once InconsistentNaming - SD_PAL_NC = 0x00000020, - - /// - /// Extended definition with height of 576 pixels interlaced - /// - // ReSharper disable once InconsistentNaming - SD576i = 0x00000100, - - /// - /// Extended definition with height of 480 pixels interlaced - /// - // ReSharper disable once InconsistentNaming - SD480i = 0x00000200, - - /// - /// Extended definition with height of 480 pixels progressive - /// - // ReSharper disable once InconsistentNaming - ED480p = 0x00000400, - - /// - /// Extended definition with height of 576 pixels progressive - /// - // ReSharper disable once InconsistentNaming - ED576p = 0x00000800, - - /// - /// High definition with height of 720 pixels progressive - /// - // ReSharper disable once InconsistentNaming - HD720p = 0x00001000, - - /// - /// High definition with height of 1080 pixels interlaced - /// - // ReSharper disable once InconsistentNaming - HD1080i = 0x00002000, - - /// - /// High definition with height of 1080 pixels progressive - /// - // ReSharper disable once InconsistentNaming - HD1080p = 0x00004000, - - /// - /// High definition 50 frames per second with height of 720 pixels progressive - /// - // ReSharper disable once InconsistentNaming - HD720p50 = 0x00008000, - - /// - /// High definition 24 frames per second with height of 1080 pixels progressive - /// - // ReSharper disable once InconsistentNaming - HD1080p24 = 0x00010000, - - /// - /// High definition 50 frames per second with height of 1080 pixels interlaced - /// - // ReSharper disable once InconsistentNaming - HD1080i50 = 0x00020000, - - /// - /// High definition 50 frames per second with height of 1080 pixels progressive - /// - // ReSharper disable once InconsistentNaming - HD1080p50 = 0x00040000, - - /// - /// Ultra high definition 30 frames per second - /// - // ReSharper disable once InconsistentNaming - UHD4Kp30 = 0x00080000, - - /// - /// Ultra high definition 30 frames per second with width of 3840 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp30_3840 = UHD4Kp30, - - /// - /// Ultra high definition 25 frames per second - /// - // ReSharper disable once InconsistentNaming - UHD4Kp25 = 0x00100000, - - /// - /// Ultra high definition 25 frames per second with width of 3840 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp25_3840 = UHD4Kp25, - - /// - /// Ultra high definition 24 frames per second - /// - // ReSharper disable once InconsistentNaming - UHD4Kp24 = 0x00200000, - - /// - /// Ultra high definition 24 frames per second with width of 3840 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp24_3840 = UHD4Kp24, - - /// - /// Ultra high definition 24 frames per second with SMPTE signal - /// - // ReSharper disable once InconsistentNaming - UHD4Kp24_SMPTE = 0x00400000, - - /// - /// Ultra high definition 50 frames per second with width of 3840 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp50_3840 = 0x00800000, - - /// - /// Ultra high definition 60 frames per second with width of 3840 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp60_3840 = 0x00900000, - - /// - /// Ultra high definition 30 frames per second with width of 4096 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp30_4096 = 0x00A00000, - - /// - /// Ultra high definition 25 frames per second with width of 4096 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp25_4096 = 0x00B00000, - - /// - /// Ultra high definition 24 frames per second with width of 4096 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp24_4096 = 0x00C00000, - - /// - /// Ultra high definition 50 frames per second with width of 4096 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp50_4096 = 0x00D00000, - - /// - /// Ultra high definition 60 frames per second with width of 4096 pixels - /// - // ReSharper disable once InconsistentNaming - UHD4Kp60_4096 = 0x00E00000, - - /// - /// Any other standard definition TV format - /// - SDOther = 0x01000000, - - /// - /// Any other extended definition TV format - /// - EDOther = 0x02000000, - - /// - /// Any other high definition TV format - /// - HDOther = 0x04000000, - - /// - /// Any other TV format - /// - Any = 0x80000000 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TargetViewMode.cs b/app/NvAPIWrapper/Native/Display/TargetViewMode.cs deleted file mode 100644 index 39f24b14..00000000 --- a/app/NvAPIWrapper/Native/Display/TargetViewMode.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Display view modes - /// - public enum TargetViewMode - { - /// - /// Standard view mode - /// - Standard = 0, - - /// - /// Cloned view mode - /// - Clone = 1, - - /// - /// Horizontal span view mode - /// - HorizontalSpan = 2, - - /// - /// Vertical span view mode - /// - VerticalSpan = 3, - - /// - /// Dual view mode - /// - DualView = 4, - - /// - /// Multi view mode - /// - MultiView = 5 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TimingHorizontalSyncPolarity.cs b/app/NvAPIWrapper/Native/Display/TimingHorizontalSyncPolarity.cs deleted file mode 100644 index 90c541cb..00000000 --- a/app/NvAPIWrapper/Native/Display/TimingHorizontalSyncPolarity.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Horizontal synchronized polarity modes - /// - public enum TimingHorizontalSyncPolarity : byte - { - /// - /// Positive horizontal synchronized polarity - /// - Positive = 0, - - /// - /// Negative horizontal synchronized polarity - /// - Negative = 1, - - /// - /// Default horizontal synchronized polarity - /// - Default = Negative - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TimingOverride.cs b/app/NvAPIWrapper/Native/Display/TimingOverride.cs deleted file mode 100644 index ead2b6d0..00000000 --- a/app/NvAPIWrapper/Native/Display/TimingOverride.cs +++ /dev/null @@ -1,88 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Timing override modes - /// - public enum TimingOverride - { - /// - /// Current timing - /// - Current = 0, - - /// - /// Auto timing - /// - Auto, - - /// - /// EDID timing - /// - EDID, - - /// - /// VESA DMT timing - /// - DMT, - - /// - /// VESA DMT timing with reduced blanking - /// - DMTReducedBlanking, - - /// - /// VESA CVT timing - /// - CVT, - - /// - /// VESA CVT timing with reduced blanking - /// - CVTReducedBlanking, - - /// - /// VESA GTF - /// - GTF, - - /// - /// EIA 861x PreDefined timing - /// - EIA861, - - /// - /// AnalogTV PreDefined timing - /// - AnalogTV, - - /// - /// NVIDIA Custom timing - /// - Custom, - - /// - /// NVIDIA PreDefined timing - /// - Predefined, - - /// - /// NVIDIA PreDefined timing - /// - PSF = Predefined, - - /// - /// ASPR timing - /// - ASPR, - - /// - /// Override for SDI timing - /// - SDI, - - /// - /// Not used - /// - Max - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TimingScanMode.cs b/app/NvAPIWrapper/Native/Display/TimingScanMode.cs deleted file mode 100644 index a4d42711..00000000 --- a/app/NvAPIWrapper/Native/Display/TimingScanMode.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Timing scan modes - /// - public enum TimingScanMode : ushort - { - /// - /// Progressive scan mode - /// - Progressive = 0, - - /// - /// Interlaced scan mode - /// - Interlaced = 1, - - /// - /// Interlaced scan mode with extra vertical blank - /// - InterlacedWithExtraVerticalBlank = 1, - - /// - /// Interlaced scan mode without extra vertical blank - /// - InterlacedWithNoExtraVerticalBlank = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/TimingVerticalSyncPolarity.cs b/app/NvAPIWrapper/Native/Display/TimingVerticalSyncPolarity.cs deleted file mode 100644 index 3bf5292d..00000000 --- a/app/NvAPIWrapper/Native/Display/TimingVerticalSyncPolarity.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Vertical synchronized polarity modes - /// - public enum TimingVerticalSyncPolarity : byte - { - /// - /// Positive vertical synchronized polarity - /// - Positive = 0, - - /// - /// Negative vertical synchronized polarity - /// - Negative = 1, - - /// - /// Default vertical synchronized polarity - /// - Default = Positive - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Display/WarpingVerticeFormat.cs b/app/NvAPIWrapper/Native/Display/WarpingVerticeFormat.cs deleted file mode 100644 index 87dbc7d6..00000000 --- a/app/NvAPIWrapper/Native/Display/WarpingVerticeFormat.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Display -{ - /// - /// Holds a list of possible warping vertex formats - /// - public enum WarpingVerticeFormat : uint - { - /// - /// XYUVRQ Triangle Strip vertex format - /// - TriangleStripXYUVRQ = 0, - - /// - /// XYUVRQ Triangles format - /// - TrianglesXYUVRQ = 1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/DisplayApi.cs b/app/NvAPIWrapper/Native/DisplayApi.cs deleted file mode 100644 index 380a9421..00000000 --- a/app/NvAPIWrapper/Native/DisplayApi.cs +++ /dev/null @@ -1,1675 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.Display; -using NvAPIWrapper.Native.Interfaces.GPU; -using Rectangle = NvAPIWrapper.Native.General.Structures.Rectangle; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains display and display control static functions - /// - public static class DisplayApi - { - /// - /// This API controls the display color configurations. - /// - /// The targeted display id. - /// The structure to be filled with information requested or applied on the display. - public static void ColorControl(uint displayId, ref TColorData colorData) - where TColorData : struct, IColorData - { - var c = colorData as IColorData; - ColorControl(displayId, ref c); - colorData = (TColorData) c; - } - - /// - /// This API controls the display color configurations. - /// - /// The targeted display id. - /// The structure to be filled with information requested or applied on the display. - public static void ColorControl(uint displayId, ref IColorData colorData) - { - var colorControl = DelegateFactory.GetDelegate(); - var type = colorData.GetType(); - - if (!colorControl.Accepts().Contains(type)) - { - throw new ArgumentOutOfRangeException(nameof(type)); - } - - using (var colorDataReference = ValueTypeReference.FromValueType(colorData, type)) - { - var status = colorControl(displayId, colorDataReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - colorData = colorDataReference.ToValueType(type); - } - } - - /// - /// This API controls the display color configurations. - /// - /// The targeted display id. - /// The list of structures to be filled with information requested or applied on the display. - /// The structure that succeed in requesting information or used for applying configuration on the display. - // ReSharper disable once IdentifierTypo - public static IColorData ColorControl(uint displayId, IColorData[] colorDatas) - { - foreach (var colorData in colorDatas) - { - try - { - var c = colorData; - ColorControl(displayId, ref c); - - return c; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.IncompatibleStructureVersion) - { - continue; - } - - throw; - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This function converts the unattached display handle to an active attached display handle. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// - /// An unattached display handle to convert. - /// Display handle of newly created display. - /// Status.InvalidArgument: Invalid UnAttachedDisplayHandle handle. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// A delegate callback throws an exception. - public static DisplayHandle CreateDisplayFromUnAttachedDisplay(UnAttachedDisplayHandle display) - { - var createDisplayFromUnAttachedDisplay = - DelegateFactory.GetDelegate(); - var status = createDisplayFromUnAttachedDisplay(display, out var newDisplay); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return newDisplay; - } - - /// - /// This function deletes the custom display configuration, specified from the registry for all the displays whose - /// display IDs are passed. - /// - /// Array of display IDs on which custom display configuration should be removed. - /// The custom display to remove. - public static void DeleteCustomDisplay(uint[] displayIds, CustomDisplay customDisplay) - { - if (displayIds.Length == 0) - { - return; - } - - using (var displayIdsReference = ValueTypeArray.FromArray(displayIds)) - { - using (var customDisplayReference = ValueTypeReference.FromValueType(customDisplay)) - { - var status = DelegateFactory.GetDelegate()( - displayIdsReference, - (uint) displayIds.Length, - customDisplayReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } - - /// - /// This API enumerates the custom timing specified by the enum index. - /// - /// The display id of the display. - /// A list of - public static IEnumerable EnumCustomDisplays(uint displayId) - { - var instance = typeof(CustomDisplay).Instantiate(); - - using (var customDisplayReference = ValueTypeReference.FromValueType(instance)) - { - for (uint i = 0; i < uint.MaxValue; i++) - { - var status = DelegateFactory.GetDelegate()( - displayId, - i, - customDisplayReference - ); - - if (status == Status.EndEnumeration) - { - yield break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - yield return customDisplayReference.ToValueType().GetValueOrDefault(); - } - } - } - - /// - /// This function returns the handle of all NVIDIA displays - /// Note: Display handles can get invalidated on a mode-set, so the calling applications need to re-enum the handles - /// after every mode-set. - /// - /// Array of display handles. - /// Status.NvidiaDeviceNotFound: No NVIDIA device found in the system - /// A delegate callback throws an exception. - public static DisplayHandle[] EnumNvidiaDisplayHandle() - { - var enumNvidiaDisplayHandle = - DelegateFactory.GetDelegate(); - var results = new List(); - uint i = 0; - - while (true) - { - var status = enumNvidiaDisplayHandle(i, out var displayHandle); - - if (status == Status.EndEnumeration) - { - break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - results.Add(displayHandle); - i++; - } - - return results.ToArray(); - } - - /// - /// This function returns the handle of all unattached NVIDIA displays - /// Note: Display handles can get invalidated on a mode-set, so the calling applications need to re-enum the handles - /// after every mode-set. - /// - /// Array of unattached display handles. - /// Status.NvidiaDeviceNotFound: No NVIDIA device found in the system - /// A delegate callback throws an exception. - public static UnAttachedDisplayHandle[] EnumNvidiaUnAttachedDisplayHandle() - { - var enumNvidiaUnAttachedDisplayHandle = - DelegateFactory.GetDelegate(); - var results = new List(); - uint i = 0; - - while (true) - { - var status = enumNvidiaUnAttachedDisplayHandle(i, out var displayHandle); - - if (status == Status.EndEnumeration) - { - break; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - results.Add(displayHandle); - i++; - } - - return results.ToArray(); - } - - /// - /// This function gets the active outputId associated with the display handle. - /// - /// - /// NVIDIA Display selection. It can be DisplayHandle.DefaultHandle or a handle enumerated from - /// DisplayApi.EnumNVidiaDisplayHandle(). - /// - /// - /// The active display output ID associated with the selected display handle hNvDisplay. The output id will have - /// only one bit set. In the case of Clone or Span mode, this will indicate the display outputId of the primary display - /// that the GPU is driving. - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedDisplayHandle: display is not a valid display handle. - /// A delegate callback throws an exception. - public static OutputId GetAssociatedDisplayOutputId(DisplayHandle display) - { - var getAssociatedDisplayOutputId = - DelegateFactory.GetDelegate(); - var status = getAssociatedDisplayOutputId(display, out var outputId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return outputId; - } - - /// - /// This function returns the handle of the NVIDIA display that is associated with the given display "name" (such as - /// "\\.\DISPLAY1"). - /// - /// Display name - /// Display handle of associated display - /// Status.InvalidArgument: Display name is null. - /// Status.NvidiaDeviceNotFound: No NVIDIA device maps to that display name. - /// A delegate callback throws an exception. - public static DisplayHandle GetAssociatedNvidiaDisplayHandle(string name) - { - var getAssociatedNvidiaDisplayHandle = - DelegateFactory.GetDelegate(); - var status = getAssociatedNvidiaDisplayHandle(name, out var display); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return display; - } - - /// - /// For a given NVIDIA display handle, this function returns a string (such as "\\.\DISPLAY1") to identify the display. - /// - /// Handle of the associated display - /// Name of the display - /// Status.InvalidArgument: Display handle is null. - /// Status.NvidiaDeviceNotFound: No NVIDIA device maps to that display name. - /// A delegate callback throws an exception. - public static string GetAssociatedNvidiaDisplayName(DisplayHandle display) - { - var getAssociatedNvidiaDisplayName = - DelegateFactory.GetDelegate(); - var status = getAssociatedNvidiaDisplayName(display, out var displayName); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayName.Value; - } - - /// - /// This function returns the handle of an unattached NVIDIA display that is associated with the given display "name" - /// (such as "\\DISPLAY1"). - /// - /// Display name - /// Display handle of associated unattached display - /// Status.InvalidArgument: Display name is null. - /// Status.NvidiaDeviceNotFound: No NVIDIA device maps to that display name. - /// A delegate callback throws an exception. - public static UnAttachedDisplayHandle GetAssociatedUnAttachedNvidiaDisplayHandle(string name) - { - var getAssociatedUnAttachedNvidiaDisplayHandle = - DelegateFactory.GetDelegate(); - var status = getAssociatedUnAttachedNvidiaDisplayHandle(name, out var display); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return display; - } - - /// - /// This API lets caller retrieve the current global display configuration. - /// Note: User should dispose all returned PathInfo objects - /// - /// Array of path information - /// This operation is not supported. - /// Status.InvalidArgument: Invalid input parameter. - /// Status.DeviceBusy: ModeSet has not yet completed. Please wait and call it again. - /// A delegate callback throws an exception. - public static IPathInfo[] GetDisplayConfig() - { - var getDisplayConfig = DelegateFactory.GetDelegate(); - uint allAvailable = 0; - var status = getDisplayConfig(ref allAvailable, ValueTypeArray.Null); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (allAvailable == 0) - { - return new IPathInfo[0]; - } - - foreach (var acceptType in getDisplayConfig.Accepts()) - { - var count = allAvailable; - var instances = acceptType.Instantiate().Repeat((int) allAvailable); - - using (var pathInfos = ValueTypeArray.FromArray(instances, acceptType)) - { - status = getDisplayConfig(ref count, pathInfos); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - instances = pathInfos.ToArray((int) count, acceptType); - } - - if (instances.Length <= 0) - { - return new IPathInfo[0]; - } - - // After allocation, we should make sure to dispose objects - // In this case however, the responsibility is on the user shoulders - instances = instances.AllocateAll().ToArray(); - - using (var pathInfos = ValueTypeArray.FromArray(instances, acceptType)) - { - status = getDisplayConfig(ref count, pathInfos); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return pathInfos.ToArray((int) count, acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// Gets the build title of the Driver Settings Database for a display - /// - /// The display handle to get DRS build title. - /// The DRS build title. - public static string GetDisplayDriverBuildTitle(DisplayHandle displayHandle) - { - var status = - DelegateFactory.GetDelegate()(displayHandle, - out var name); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return name.Value; - } - - /// - /// This function retrieves the available driver memory footprint for the GPU associated with a display. - /// - /// Handle of the display for which the memory information of its GPU is to be extracted. - /// The memory footprint available in the driver. - /// This operation is not supported. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// A delegate callback throws an exception. - public static IDisplayDriverMemoryInfo GetDisplayDriverMemoryInfo(DisplayHandle displayHandle) - { - var getMemoryInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getMemoryInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var displayDriverMemoryInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getMemoryInfo(displayHandle, displayDriverMemoryInfo); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDriverMemoryInfo.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API retrieves the Display Id of a given display by display name. The display must be active to retrieve the - /// displayId. In the case of clone mode or Surround gaming, the primary or top-left display will be returned. - /// - /// Name of display (Eg: "\\DISPLAY1" to retrieve the displayId for. - /// Display ID of the requested display. - /// Status.InvalidArgument: One or more args passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first - /// Status.NoImplementation: This entry-point not available - /// Status.Error: Miscellaneous error occurred - /// A delegate callback throws an exception. - public static uint GetDisplayIdByDisplayName(string displayName) - { - var getDisplayIdByDisplayName = - DelegateFactory.GetDelegate(); - var status = getDisplayIdByDisplayName(displayName, out var display); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return display; - } - - /// [PRIVATE] - /// - /// This API returns the current saturation level from the Digital Vibrance Control - /// - /// - /// The targeted display's handle. - /// - /// An instance of the PrivateDisplayDVCInfo structure containing requested information. - public static PrivateDisplayDVCInfo GetDVCInfo(DisplayHandle display) - { - var instance = typeof(PrivateDisplayDVCInfo).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// [PRIVATE] - /// - /// This API returns the current saturation level from the Digital Vibrance Control - /// - /// - /// The targeted display output id. - /// - /// An instance of the PrivateDisplayDVCInfo structure containing requested information. - public static PrivateDisplayDVCInfo GetDVCInfo(OutputId displayId) - { - var instance = typeof(PrivateDisplayDVCInfo).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// [PRIVATE] - /// - /// This API returns the current and the default saturation level from the Digital Vibrance Control. - /// The difference between this API and the 'GetDVCInfo()' includes the possibility to get the default - /// saturation level as well as to query under saturated configurations. - /// - /// - /// The targeted display's handle. - /// - /// An instance of the PrivateDisplayDVCInfoEx structure containing requested information. - public static PrivateDisplayDVCInfoEx GetDVCInfoEx(DisplayHandle display) - { - var instance = typeof(PrivateDisplayDVCInfoEx).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// [PRIVATE] - /// - /// This API returns the current and the default saturation level from the Digital Vibrance Control. - /// The difference between this API and the 'GetDVCInfo()' includes the possibility to get the default - /// saturation level as well as to query under saturated configurations. - /// - /// - /// The targeted display output id. - /// - /// An instance of the PrivateDisplayDVCInfoEx structure containing requested information. - public static PrivateDisplayDVCInfoEx GetDVCInfoEx(OutputId displayId) - { - var instance = typeof(PrivateDisplayDVCInfoEx).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API returns the current info-frame data on the specified device (monitor). - /// - /// The display handle of the device to retrieve HDMI support information for. - /// The target display's output id, or to determine automatically. - /// An instance of a type implementing the interface. - public static IHDMISupportInfo GetHDMISupportInfo(DisplayHandle displayHandle, OutputId outputId = OutputId.Invalid) - { - var getHDMISupportInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getHDMISupportInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var supportInfoReference = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getHDMISupportInfo(displayHandle, (uint)outputId, supportInfoReference); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return supportInfoReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API returns the current info-frame data on the specified device (monitor). - /// - /// The display id of the device to retrieve HDMI support information for. - /// An instance of a type implementing the interface. - public static IHDMISupportInfo GetHDMISupportInfo(uint displayId) - { - var getHDMISupportInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getHDMISupportInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var supportInfoReference = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getHDMISupportInfo(DisplayHandle.DefaultHandle, displayId, supportInfoReference); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return supportInfoReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// [PRIVATE] - /// - /// This API returns the current default HUE angle - /// - /// - /// The targeted display's handle. - /// - /// An instance of the PrivateDisplayHUEInfo structure containing requested information. - public static PrivateDisplayHUEInfo GetHUEInfo(DisplayHandle display) - { - var instance = typeof(PrivateDisplayHUEInfo).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// [PRIVATE] - /// - /// This API returns the current and default HUE angle - /// - /// - /// The targeted display output id. - /// - /// An instance of the PrivateDisplayHUEInfo structure containing requested information. - public static PrivateDisplayHUEInfo GetHUEInfo(OutputId displayId) - { - var instance = typeof(PrivateDisplayHUEInfo).Instantiate(); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDVCInfoReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API returns all the monitor capabilities. - /// - /// The target display id. - /// The type of capabilities requested. - /// An instance of . - public static MonitorCapabilities? GetMonitorCapabilities( - uint displayId, - MonitorCapabilitiesType capabilitiesType) - { - var instance = new MonitorCapabilities(capabilitiesType); - - using (var monitorCapReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - monitorCapReference - ); - - if (status == Status.Error) - { - return null; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - - instance = monitorCapReference.ToValueType().GetValueOrDefault(); - - if (!instance.IsValid) - { - return null; - } - - return instance; - } - } - - /// - /// This API returns all the color formats and bit depth values supported by a given display port monitor. - /// - /// The target display id. - /// A list of instances. - public static MonitorColorData[] GetMonitorColorCapabilities(uint displayId) - { - var getMonitorColorCapabilities = - DelegateFactory.GetDelegate(); - var count = 0u; - - var status = getMonitorColorCapabilities(displayId, ValueTypeArray.Null, ref count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (count == 0) - { - return new MonitorColorData[0]; - } - - var array = typeof(MonitorColorData).Instantiate().Repeat((int) count); - - using (var monitorCapsReference = ValueTypeArray.FromArray(array)) - { - status = getMonitorColorCapabilities(displayId, monitorCapsReference, ref count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return monitorCapsReference.ToArray((int) count); - - } - } - - /// - /// This API returns the Display ID of the GDI Primary. - /// - /// Display ID of the GDI Primary. - /// Status.NvidiaDeviceNotFound: GDI Primary not on an NVIDIA GPU. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first - /// Status.NoImplementation: This entry-point not available - /// Status.Error: Miscellaneous error occurred - /// A delegate callback throws an exception. - public static uint GetGDIPrimaryDisplayId() - { - var getGDIPrimaryDisplay = - DelegateFactory.GetDelegate(); - var status = getGDIPrimaryDisplay(out var displayId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayId; - } - - /// - /// This API gets High Dynamic Range (HDR) capabilities of the display. - /// - /// The targeted display id. - /// - /// A boolean value indicating if the EDID HDR parameters should be expanded (true) or the actual current HDR - /// parameters should be reported (false). - /// - /// HDR capabilities of the display - public static HDRCapabilitiesV1 GetHDRCapabilities(uint displayId, bool driverExpandDefaultHDRParameters) - { - var hdrCapabilities = new HDRCapabilitiesV1(driverExpandDefaultHDRParameters); - - using (var hdrCapabilitiesReference = ValueTypeReference.FromValueType(hdrCapabilities)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - hdrCapabilitiesReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return hdrCapabilitiesReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API queries current state of one of the various scan-out composition parameters on the specified display. - /// - /// Combined physical display and GPU identifier of the display to query the configuration. - /// Scan-out composition parameter to by queried. - /// Additional container containing the returning data associated with the specified parameter. - /// Scan-out composition parameter value. - public static ScanOutCompositionParameterValue GetScanOutCompositionParameter( - uint displayId, - ScanOutCompositionParameter parameter, - out float container) - { - var status = DelegateFactory.GetDelegate()( - displayId, - parameter, - out var parameterValue, - out container - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return parameterValue; - } - - /// - /// This API queries the desktop and scan-out portion of the specified display. - /// - /// Combined physical display and GPU identifier of the display to query the configuration. - /// Desktop area to displayId mapping information. - public static ScanOutInformationV1 GetScanOutConfiguration(uint displayId) - { - var instance = typeof(ScanOutInformationV1).Instantiate(); - - using (var scanOutInformationReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - scanOutInformationReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return scanOutInformationReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API queries the desktop and scan-out portion of the specified display. - /// - /// Combined physical display and GPU identifier of the display to query the configuration. - /// Desktop area of the display in desktop coordinates. - /// Scan-out area of the display relative to desktopRect. - public static void GetScanOutConfiguration( - uint displayId, - out Rectangle desktopRectangle, - out Rectangle scanOutRectangle) - { - var instance1 = typeof(Rectangle).Instantiate(); - var instance2 = typeof(Rectangle).Instantiate(); - - using (var desktopRectangleReference = ValueTypeReference.FromValueType(instance1)) - { - using (var scanOutRectangleReference = ValueTypeReference.FromValueType(instance2)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - desktopRectangleReference, - scanOutRectangleReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - desktopRectangle = desktopRectangleReference.ToValueType().GetValueOrDefault(); - scanOutRectangle = scanOutRectangleReference.ToValueType().GetValueOrDefault(); - } - } - } - - /// - /// This API queries current state of the intensity feature on the specified display. - /// - /// Combined physical display and GPU identifier of the display to query the configuration. - /// Intensity state data. - public static ScanOutIntensityStateV1 GetScanOutIntensityState(uint displayId) - { - var instance = typeof(ScanOutIntensityStateV1).Instantiate(); - - using (var scanOutIntensityReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - scanOutIntensityReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return scanOutIntensityReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API queries current state of the warping feature on the specified display. - /// - /// Combined physical display and GPU identifier of the display to query the configuration. - /// The warping state data. - public static ScanOutWarpingStateV1 GetScanOutWarpingState(uint displayId) - { - var instance = typeof(ScanOutWarpingStateV1).Instantiate(); - - using (var scanOutWarpingReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - scanOutWarpingReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return scanOutWarpingReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API lets caller enumerate all the supported NVIDIA display views - nView and DualView modes. - /// - /// - /// NVIDIA Display selection. It can be DisplayHandle.DefaultHandle or a handle enumerated from - /// DisplayApi.EnumNVidiaDisplayHandle(). - /// - /// Array of supported views. - /// This operation is not supported. - /// Status.Error: Miscellaneous error occurred - /// Status.InvalidArgument: Invalid input parameter. - /// A delegate callback throws an exception. - public static TargetViewMode[] GetSupportedViews(DisplayHandle display) - { - var getSupportedViews = DelegateFactory.GetDelegate(); - uint allAvailable = 0; - var status = getSupportedViews(display, ValueTypeArray.Null, ref allAvailable); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (allAvailable == 0) - { - return new TargetViewMode[0]; - } - - if (!getSupportedViews.Accepts().Contains(typeof(TargetViewMode))) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - using ( - var viewModes = - ValueTypeArray.FromArray(TargetViewMode.Standard.Repeat((int) allAvailable).Cast(), - typeof(TargetViewMode).GetEnumUnderlyingType())) - { - status = getSupportedViews(display, viewModes, ref allAvailable); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return viewModes.ToArray((int) allAvailable, - typeof(TargetViewMode).GetEnumUnderlyingType()); - } - } - - /// - /// This function calculates the timing from the visible width/height/refresh-rate and timing type info. - /// - /// Display ID of the display. - /// Inputs used for calculating the timing. - /// An instance of the structure. - public static Timing GetTiming(uint displayId, TimingInput timingInput) - { - var instance = typeof(Timing).Instantiate(); - - using (var timingInputReference = ValueTypeReference.FromValueType(timingInput)) - { - using (var timingReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - displayId, - timingInputReference, - timingReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return timingReference.ToValueType().GetValueOrDefault(); - } - } - } - - /// - /// This function returns the display name given, for example, "\\DISPLAY1", using the unattached NVIDIA display handle - /// - /// Handle of the associated unattached display - /// Name of the display - /// Status.InvalidArgument: Display handle is null. - /// Status.NvidiaDeviceNotFound: No NVIDIA device maps to that display name. - /// A delegate callback throws an exception. - public static string GetUnAttachedAssociatedDisplayName(UnAttachedDisplayHandle display) - { - var getUnAttachedAssociatedDisplayName = - DelegateFactory.GetDelegate(); - var status = getUnAttachedAssociatedDisplayName(display, out var displayName); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayName.Value; - } - - /// - /// This API controls the InfoFrame values. - /// - /// The targeted display id. - /// The structure to be filled with information requested or applied on the display. - public static void InfoFrameControl(uint displayId, ref InfoFrameData infoFrameData) - { - var infoFrameControl = DelegateFactory.GetDelegate(); - - using (var infoFrameDataReference = ValueTypeReference.FromValueType(infoFrameData)) - { - var status = infoFrameControl(displayId, infoFrameDataReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - infoFrameData = infoFrameDataReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This API is used to restore the display configuration, that was changed by calling . - /// This function must be called only after a custom display configuration is tested on the hardware, using - /// , otherwise no action is taken. - /// On Vista, should be called with an active display that was affected during - /// the call, per GPU. - /// - /// Array of display ids on which custom display configuration is to be reverted. - public static void RevertCustomDisplayTrial(uint[] displayIds) - { - if (displayIds.Length == 0) - { - return; - } - - using (var displayIdsReference = ValueTypeArray.FromArray(displayIds)) - { - var status = DelegateFactory.GetDelegate()( - displayIdsReference, - (uint) displayIds.Length - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This API configures High Dynamic Range (HDR) and Extended Dynamic Range (EDR) output. - /// - /// The targeted display id. - /// The structure to be filled with information requested or applied on the display. - public static void HDRColorControl(uint displayId, ref THDRColorData hdrColorData) - where THDRColorData : struct, IHDRColorData - { - var c = hdrColorData as IHDRColorData; - HDRColorControl(displayId, ref c); - hdrColorData = (THDRColorData)c; - } - - /// - /// This API configures High Dynamic Range (HDR) and Extended Dynamic Range (EDR) output. - /// - /// The targeted display id. - /// The structure to be filled with information requested or applied on the display. - public static void HDRColorControl(uint displayId, ref IHDRColorData hdrColorData) - { - var hdrColorControl = DelegateFactory.GetDelegate(); - var type = hdrColorData.GetType(); - - if (!hdrColorControl.Accepts().Contains(type)) - { - throw new ArgumentOutOfRangeException(nameof(type)); - } - - using (var hdrColorDataReference = ValueTypeReference.FromValueType(hdrColorData, type)) - { - var status = hdrColorControl(displayId, hdrColorDataReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - hdrColorData = hdrColorDataReference.ToValueType(type); - } - } - - /// - /// This function saves the current hardware display configuration on the specified Display IDs as a custom display - /// configuration. - /// This function should be called right after to save the custom display from the - /// current hardware context. - /// This function will not do anything if the custom display configuration is not tested on the hardware. - /// - /// Array of display ids on which custom display configuration is to be saved. - /// - /// If set, the saved custom display will only be applied on the monitor with the same - /// outputId. - /// - /// - /// If set, the saved custom display will only be applied on the monitor with the same EDID - /// ID or the same TV connector in case of analog TV. - /// - public static void SaveCustomDisplay(uint[] displayIds, bool isThisOutputIdOnly, bool isThisMonitorOnly) - { - if (displayIds.Length == 0) - { - return; - } - - using (var displayIdsReference = ValueTypeArray.FromArray(displayIds)) - { - var status = DelegateFactory.GetDelegate()( - displayIdsReference, - (uint) displayIds.Length, - isThisOutputIdOnly ? 1 : (uint) 0, - isThisMonitorOnly ? 1 : (uint) 0 - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This API configures High Dynamic Range (HDR) and Extended Dynamic Range (EDR) output. - /// - /// The targeted display id. - /// The list of structures to be filled with information requested or applied on the display. - /// The structure that succeed in requesting information or used for applying configuration on the display. - // ReSharper disable once IdentifierTypo - public static IHDRColorData HDRColorControl(uint displayId, IHDRColorData[] colorDatas) - { - foreach (var colorData in colorDatas) - { - try - { - var c = colorData; - HDRColorControl(displayId, ref c); - - return c; - } - catch (NVIDIAApiException e) - { - if (e.Status == Status.IncompatibleStructureVersion) - { - continue; - } - - throw; - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API lets caller apply a global display configuration across multiple GPUs. - /// If all sourceIds are zero, then NvAPI will pick up sourceId's based on the following criteria : - /// - If user provides SourceModeInfo then we are trying to assign 0th SourceId always to GDIPrimary. - /// This is needed since active windows always moves along with 0th sourceId. - /// - For rest of the paths, we are incrementally assigning the SourceId per adapter basis. - /// - If user doesn't provide SourceModeInfo then NVAPI just picks up some default SourceId's in incremental order. - /// Note : NVAPI will not intelligently choose the SourceIDs for any configs that does not need a mode-set. - /// - /// Array of path information - /// Flags for applying settings - /// This operation is not supported. - /// Status.ApiNotInitialized: NVAPI not initialized - /// Status.Error: Miscellaneous error occurred - /// Status.InvalidArgument: Invalid input parameter. - /// A delegate callback throws an exception. - public static void SetDisplayConfig(IPathInfo[] pathInfos, DisplayConfigFlags flags) - { - var setDisplayConfig = DelegateFactory.GetDelegate(); - - if (pathInfos.Length > 0 && !setDisplayConfig.Accepts().Contains(pathInfos[0].GetType())) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - using (var arrayReference = ValueTypeArray.FromArray(pathInfos)) - { - var status = setDisplayConfig((uint) pathInfos.Length, arrayReference, flags); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// [PRIVATE] - /// - /// This API sets the current saturation level for the Digital Vibrance Control - /// - /// - /// The targeted display's handle. - /// - /// - /// The saturation level to be set. - /// - public static void SetDVCLevel(DisplayHandle display, int currentLevel) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - currentLevel - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// [PRIVATE] - /// - /// This API sets the current saturation level for the Digital Vibrance Control - /// - /// - /// The targeted display output id. - /// - /// - /// The saturation level to be set. - /// - public static void SetDVCLevel(OutputId displayId, int currentLevel) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - currentLevel - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// [PRIVATE] - /// - /// This API sets the current saturation level for the Digital Vibrance Control. - /// The difference between this API and the 'SetDVCLevel()' includes the possibility to set under saturated - /// levels. - /// - /// - /// The targeted display's handle. - /// - /// - /// The saturation level to be set. - /// - public static void SetDVCLevelEx(DisplayHandle display, int currentLevel) - { - var instance = new PrivateDisplayDVCInfoEx(currentLevel); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// [PRIVATE] - /// - /// This API sets the current saturation level for the Digital Vibrance Control. - /// The difference between this API and the 'SetDVCLevel()' includes the possibility to set under saturated - /// levels. - /// - /// - /// The targeted display output id. - /// - /// - /// The saturation level to be set. - /// - public static void SetDVCLevelEx(OutputId displayId, int currentLevel) - { - var instance = new PrivateDisplayDVCInfoEx(currentLevel); - - using (var displayDVCInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - displayDVCInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// [PRIVATE] - /// - /// This API sets the current HUE angle - /// - /// - /// The targeted display's handle. - /// - /// - /// The HUE angle to be set. - /// - public static void SetHUEAngle(DisplayHandle display, int currentAngle) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - currentAngle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// [PRIVATE] - /// - /// This API sets the current HUE angle - /// - /// - /// The targeted display output id. - /// - /// - /// The HUE angle to be set. - /// - public static void SetHUEAngle(OutputId displayId, int currentAngle) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - displayId, - currentAngle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function overrides the refresh rate on the given display. - /// The new refresh rate can be applied right away in this API call or deferred to be applied with the next OS - /// mode-set. - /// The override is good for only one mode-set (regardless whether it's deferred or immediate). - /// - /// The display handle to override refresh rate of. - /// The override refresh rate. - /// - /// A boolean value indicating if the refresh rate override should be deferred to the next OS - /// mode-set. - /// - public static void SetRefreshRateOverride(DisplayHandle display, float refreshRate, bool isDeferred) - { - var status = DelegateFactory.GetDelegate()( - display, - OutputId.Invalid, - refreshRate, - isDeferred ? 1u : 0 - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function overrides the refresh rate on the given output mask. - /// The new refresh rate can be applied right away in this API call or deferred to be applied with the next OS - /// mode-set. - /// The override is good for only one mode-set (regardless whether it's deferred or immediate). - /// - /// The output(s) to override refresh rate of. - /// The override refresh rate. - /// - /// A boolean value indicating if the refresh rate override should be deferred to the next OS - /// mode-set. - /// - public static void SetRefreshRateOverride(OutputId outputMask, float refreshRate, bool isDeferred) - { - var status = DelegateFactory.GetDelegate()( - DisplayHandle.DefaultHandle, - outputMask, - refreshRate, - isDeferred ? 1u : 0 - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets various parameters that configure the scan-out composition feature on the specified display. - /// - /// Combined physical display and GPU identifier of the display to apply the intensity control. - /// The scan-out composition parameter to be set. - /// The value to be set for the specified parameter. - /// Additional container for data associated with the specified parameter. - // ReSharper disable once TooManyArguments - public static void SetScanOutCompositionParameter( - uint displayId, - ScanOutCompositionParameter parameter, - ScanOutCompositionParameterValue parameterValue, - ref float container) - { - var status = DelegateFactory.GetDelegate()( - displayId, - parameter, - parameterValue, - ref container - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API enables and sets up per-pixel intensity feature on the specified display. - /// - /// Combined physical display and GPU identifier of the display to apply the intensity control. - /// The intensity texture info. - /// Indicates whether the settings will be kept over a reboot. - public static void SetScanOutIntensity(uint displayId, IScanOutIntensity scanOutIntensity, out bool isSticky) - { - Status status; - int isStickyInt; - - if (scanOutIntensity == null) - { - status = DelegateFactory.GetDelegate()( - displayId, - ValueTypeReference.Null, - out isStickyInt - ); - } - else - { - using (var scanOutWarpingReference = - ValueTypeReference.FromValueType(scanOutIntensity, scanOutIntensity.GetType())) - { - status = DelegateFactory.GetDelegate()( - displayId, - scanOutWarpingReference, - out isStickyInt - ); - } - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - isSticky = isStickyInt > 0; - } - - /// - /// This API enables and sets up the warping feature on the specified display. - /// - /// Combined physical display and GPU identifier of the display to apply the intensity control. - /// The warping data info. - /// The maximum number of vertices. - /// Indicates whether the settings will be kept over a reboot. - // ReSharper disable once TooManyArguments - public static void SetScanOutWarping( - uint displayId, - ScanOutWarpingV1? scanOutWarping, - ref int maximumNumberOfVertices, - out bool isSticky) - { - Status status; - int isStickyInt; - - if (scanOutWarping == null || maximumNumberOfVertices == 0) - { - maximumNumberOfVertices = 0; - status = DelegateFactory.GetDelegate()( - displayId, - ValueTypeReference.Null, - ref maximumNumberOfVertices, - out isStickyInt - ); - } - else - { - using (var scanOutWarpingReference = ValueTypeReference.FromValueType(scanOutWarping.Value)) - { - status = DelegateFactory.GetDelegate()( - displayId, - scanOutWarpingReference, - ref maximumNumberOfVertices, - out isStickyInt - ); - } - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - isSticky = isStickyInt > 0; - } - - /// - /// This API is used to set up a custom display without saving the configuration on multiple displays. - /// - /// A list of display ids with corresponding custom display instances. - public static void TryCustomDisplay(IDictionary displayIdCustomDisplayPairs) - { - if (displayIdCustomDisplayPairs.Count == 0) - { - return; - } - - using (var displayIdsReference = ValueTypeArray.FromArray(displayIdCustomDisplayPairs.Keys.ToArray())) - { - using (var customDisplaysReference = - ValueTypeArray.FromArray(displayIdCustomDisplayPairs.Values.ToArray())) - { - var status = DelegateFactory.GetDelegate()( - displayIdsReference, - (uint) displayIdCustomDisplayPairs.Count, - customDisplaysReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Exceptions/NVIDIAApiException.cs b/app/NvAPIWrapper/Native/Exceptions/NVIDIAApiException.cs deleted file mode 100644 index a9a7a8d0..00000000 --- a/app/NvAPIWrapper/Native/Exceptions/NVIDIAApiException.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using NvAPIWrapper.Native.General; - -namespace NvAPIWrapper.Native.Exceptions -{ - /// - /// Represents errors that raised by NVIDIA Api - /// - public class NVIDIAApiException : Exception - { - internal NVIDIAApiException(Status status) - { - Status = status; - } - - /// - public override string Message - { - get => GeneralApi.GetErrorMessage(Status) ?? Status.ToString(); - } - - /// - /// Gets NVIDIA Api exception status code - /// - public Status Status { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Exceptions/NVIDIANotSupportedException.cs b/app/NvAPIWrapper/Native/Exceptions/NVIDIANotSupportedException.cs deleted file mode 100644 index 46bd62a8..00000000 --- a/app/NvAPIWrapper/Native/Exceptions/NVIDIANotSupportedException.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Exceptions -{ - /// - /// Represents errors that raised by NvAPIWrapper - /// - public class NVIDIANotSupportedException : NotSupportedException - { - internal NVIDIANotSupportedException(string message) : base(message) - { - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ClockLockMode.cs b/app/NvAPIWrapper/Native/GPU/ClockLockMode.cs deleted file mode 100644 index fae99b59..00000000 --- a/app/NvAPIWrapper/Native/GPU/ClockLockMode.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds the possible clock lock modes - /// - public enum ClockLockMode : uint - { - /// - /// No clock lock - /// - None = 0, - - /// - /// Manual clock lock - /// - Manual = 3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ClockType.cs b/app/NvAPIWrapper/Native/GPU/ClockType.cs deleted file mode 100644 index 3bcee7e1..00000000 --- a/app/NvAPIWrapper/Native/GPU/ClockType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Clock types to request - /// - public enum ClockType : uint - { - /// - /// Current clock frequencies - /// - CurrentClock = 0, - - /// - /// Base clock frequencies - /// - BaseClock = 1, - - /// - /// Boost clock frequencies - /// - BoostClock = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ConnectedIdsFlag.cs b/app/NvAPIWrapper/Native/GPU/ConnectedIdsFlag.cs deleted file mode 100644 index ae693708..00000000 --- a/app/NvAPIWrapper/Native/GPU/ConnectedIdsFlag.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Flags used for retrieving a list of display identifications - /// - [Flags] - public enum ConnectedIdsFlag : uint - { - /// - /// No specific flag - /// - None = 0, - - /// - /// Get un-cached connected devices - /// - UnCached = 1, - - /// - /// Get devices such that those can be selected in an SLI configuration - /// - SLI = 2, - - /// - /// Get devices such that to reflect the Lid State - /// - LidState = 4, - - /// - /// Get devices that includes the fake connected monitors - /// - Fake = 8, - - /// - /// Excludes devices that are part of the multi stream topology - /// - ExcludeList = 16 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ConnectorType.cs b/app/NvAPIWrapper/Native/GPU/ConnectorType.cs deleted file mode 100644 index 4e46a210..00000000 --- a/app/NvAPIWrapper/Native/GPU/ConnectorType.cs +++ /dev/null @@ -1,165 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Possible display connectors - /// - public enum ConnectorType : uint - { - /// - /// VGA 15 Pin connector - /// - VGA15Pin = 0x00000000, - - /// - /// TV Composite - /// - // ReSharper disable once InconsistentNaming - TV_Composite = 0x00000010, - - /// - /// TV SVideo - /// - // ReSharper disable once InconsistentNaming - TV_SVideo = 0x00000011, - - /// - /// TV HDTV Component - /// - // ReSharper disable once InconsistentNaming - TV_HDTVComponent = 0x00000013, - - /// - /// TV SCART - /// - // ReSharper disable once InconsistentNaming - TV_SCART = 0x00000014, - - /// - /// TV Composite through SCART on EIAJ4120 - /// - // ReSharper disable once InconsistentNaming - TV_CompositeSCARTOnEIAJ4120 = 0x00000016, - - /// - /// TV HDTV EIAJ4120 - /// - // ReSharper disable once InconsistentNaming - TV_HDTV_EIAJ4120 = 0x00000017, - - /// - /// HDTV YPbPr through VESA Plug On Display - /// - // ReSharper disable once InconsistentNaming - PC_POD_HDTV_YPbPr = 0x00000018, - - /// - /// SVideo through VESA Plug On Display - /// - // ReSharper disable once InconsistentNaming - PC_POD_SVideo = 0x00000019, - - /// - /// Composite through VESA Plug On Display - /// - // ReSharper disable once InconsistentNaming - PC_POD_Composite = 0x0000001A, - - /// - /// TV SVideo through DVI Integrated - /// - // ReSharper disable once InconsistentNaming - DVI_I_TV_SVideo = 0x00000020, - - /// - /// TV Composite through DVI Integrated - /// - // ReSharper disable once InconsistentNaming - DVI_I_TV_COMPOSITE = 0x00000021, - - /// - /// DVI Integrated - /// - // ReSharper disable once InconsistentNaming - DVI_I = 0x00000030, - - /// - /// DVI Digital - /// - // ReSharper disable once InconsistentNaming - DVI_D = 0x00000031, - - /// - /// Apple Display Connector - /// - ADC = 0x00000032, - - /// - /// DVI 1 through LFH - /// - // ReSharper disable once InconsistentNaming - LFH_DVI_I1 = 0x00000038, - - /// - /// DVI 2 through LFH - /// - // ReSharper disable once InconsistentNaming - LFH_DVI_I2 = 0x00000039, - - /// - /// SPWG pin-out connector - /// - SPWG = 0x00000040, - - /// - /// OEM connector - /// - OEM = 0x00000041, - - /// - /// External DisplayPort - /// - DisplayPortExternal = 0x00000046, - - /// - /// Internal DisplayPort - /// - DisplayPortInternal = 0x00000047, - - /// - /// External Mini DisplayPort - /// - DisplayPortMiniExternal = 0x00000048, - - /// - /// HDMI Analog - /// - // ReSharper disable once InconsistentNaming - HDMI_Analog = 0x00000061, - - /// - /// Mini HDMI - /// - // ReSharper disable once InconsistentNaming - HDMI_CMini = 0x00000063, - - /// - /// DisplayPort 1 through LFH - /// - LFHDisplayPort1 = 0x00000064, - - /// - /// DisplayPort 2 through LFH - /// - LFHDisplayPort2 = 0x00000065, - - /// - /// Virtual Wireless - /// - VirtualWFD = 0x00000070, - - /// - /// Unknown connector - /// - Unknown = 0xFFFFFFFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/CoolerControlMode.cs b/app/NvAPIWrapper/Native/GPU/CoolerControlMode.cs deleted file mode 100644 index 38c94257..00000000 --- a/app/NvAPIWrapper/Native/GPU/CoolerControlMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds possible cooler control modes - /// - public enum CoolerControlMode : uint - { - /// - /// No cooler control - /// - None = 0, - - /// - /// Toggle based cooler control mode - /// - Toggle, - - /// - /// Variable cooler control mode - /// - Variable - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/CoolerController.cs b/app/NvAPIWrapper/Native/GPU/CoolerController.cs deleted file mode 100644 index 9d625d9f..00000000 --- a/app/NvAPIWrapper/Native/GPU/CoolerController.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds the list of possible cooler controllers - /// - public enum CoolerController : uint - { - /// - /// No cooler controller - /// - None = 0, - - /// - /// ADI cooler controller - /// - ADI, - - /// - /// Internal cooler controller - /// - Internal - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/CoolerPolicy.cs b/app/NvAPIWrapper/Native/GPU/CoolerPolicy.cs deleted file mode 100644 index c7f6e766..00000000 --- a/app/NvAPIWrapper/Native/GPU/CoolerPolicy.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds possible cooler policies - /// - [Flags] - public enum CoolerPolicy : uint - { - /// - /// No cooler policy - /// - None = 0, - - /// - /// Manual cooler control - /// - Manual = 0b1, - - /// - /// Performance optimized cooler policy - /// - Performance = 0b10, - - /// - /// Discrete temperature based cooler policy - /// - TemperatureDiscrete = 0b100, - - /// - /// Continues temperature based cooler policy - /// - TemperatureContinuous = 0b1000, - - /// - /// Silent cooler policy - /// - Silent = 0b10000 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/CoolerTarget.cs b/app/NvAPIWrapper/Native/GPU/CoolerTarget.cs deleted file mode 100644 index f21cf1c1..00000000 --- a/app/NvAPIWrapper/Native/GPU/CoolerTarget.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of possible cooler targets - /// - [Flags] - public enum CoolerTarget : uint - { - /// - /// No cooler target - /// - None = 0, - - /// - /// Cooler targets GPU - /// - GPU = 0b1, - - /// - /// Cooler targets memory - /// - Memory = 0b10, - - /// - /// Cooler targets power supply - /// - PowerSupply = 0b100, - - /// - /// Cooler targets GPU, memory and power supply - /// - All = GPU | Memory | PowerSupply - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/CoolerType.cs b/app/NvAPIWrapper/Native/GPU/CoolerType.cs deleted file mode 100644 index edcd8fba..00000000 --- a/app/NvAPIWrapper/Native/GPU/CoolerType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of possible cooler types - /// - public enum CoolerType : uint - { - /// - /// No cooler type - /// - None, - - /// - /// Air cooling - /// - Fan, - - /// - /// Water cooling - /// - Water, - - /// - /// Liquid nitrogen cooling - /// - LiquidNitrogen - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ECCConfiguration.cs b/app/NvAPIWrapper/Native/GPU/ECCConfiguration.cs deleted file mode 100644 index 5b7f02e4..00000000 --- a/app/NvAPIWrapper/Native/GPU/ECCConfiguration.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of possible ECC memory configurations - /// - public enum ECCConfiguration : uint - { - /// - /// ECC memory configurations are not supported - /// - NotSupported = 0, - - /// - /// Changes require a POST to take effect - /// - Deferred, - - /// - /// Changes can optionally be made to take effect immediately - /// - Immediate - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/FanCoolersControlMode.cs b/app/NvAPIWrapper/Native/GPU/FanCoolersControlMode.cs deleted file mode 100644 index da4fcc33..00000000 --- a/app/NvAPIWrapper/Native/GPU/FanCoolersControlMode.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds possible fan cooler control modes - /// - [Flags] - public enum FanCoolersControlMode : uint - { - /// - /// Automatic fan cooler control - /// - Auto = 0, - - /// - /// Manual fan cooler control - /// - Manual = 0b1, - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GPUBusType.cs b/app/NvAPIWrapper/Native/GPU/GPUBusType.cs deleted file mode 100644 index d33397ed..00000000 --- a/app/NvAPIWrapper/Native/GPU/GPUBusType.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Associated GPU bus types - /// - public enum GPUBusType - { - /// - /// Bus type is undefined - /// - Undefined = 0, - - /// - /// PCI Bus - /// - PCI = 1, - - /// - /// AGP Bus - /// - AGP = 2, - - /// - /// PCIExpress Bus - /// - PCIExpress = 3, - - /// - /// FPCI Bus - /// - FPCI = 4, - - /// - /// AXI Bus - /// - AXI = 5 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GPUFoundry.cs b/app/NvAPIWrapper/Native/GPU/GPUFoundry.cs deleted file mode 100644 index 26e1aaf7..00000000 --- a/app/NvAPIWrapper/Native/GPU/GPUFoundry.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known GPU foundries - /// - [SuppressMessage("ReSharper", "IdentifierTypo")] - public enum GPUFoundry : uint - { - /// - /// Unknown foundry - /// - Unknown, - - /// - /// Taiwan Semiconductor Manufacturing Company Limited - /// - TSMC, - - /// - /// United Microelectronics - /// - UMC, - - /// - /// International Business Machines Corporation - /// - IBM, - - /// - /// Semiconductor Manufacturing International Corporation - /// - SMIC, - - /// - /// Chartered Semiconductor Manufacturing - /// - CSM, - - /// - /// Toshiba Corporation - /// - Toshiba - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GPUMemoryMaker.cs b/app/NvAPIWrapper/Native/GPU/GPUMemoryMaker.cs deleted file mode 100644 index e938992f..00000000 --- a/app/NvAPIWrapper/Native/GPU/GPUMemoryMaker.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known memory makers - /// - [SuppressMessage("ReSharper", "IdentifierTypo")] - // ReSharper disable CommentTypo - public enum GPUMemoryMaker : uint - { - /// - /// Unknown memory maker - /// - Unknown = 0, - - /// - /// Samsung Group - /// - Samsung, - - /// - /// Qimonda AG - /// - Qimonda, - - /// - /// Elpida Memory, Inc. - /// - Elpida, - - /// - /// Etron Technology, Inc. - /// - Etron, - - /// - /// Nanya Technology Corporation - /// - Nanya, - - /// - /// SK Hynix - /// - Hynix, - - /// - /// Mosel Vitelic Corporation - /// - Mosel, - - /// - /// Winbond Electronics Corporation - /// - Winbond, - - /// - /// Elite Semiconductor Memory Technology Inc. - /// - Elite, - - /// - /// Micron Technology, Inc. - /// - Micron - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GPUMemoryType.cs b/app/NvAPIWrapper/Native/GPU/GPUMemoryType.cs deleted file mode 100644 index 98f8abbc..00000000 --- a/app/NvAPIWrapper/Native/GPU/GPUMemoryType.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known memory types - /// - public enum GPUMemoryType : uint - { - /// - /// Unknown memory type - /// - Unknown = 0, - - /// - /// Synchronous dynamic random-access memory - /// - SDRAM, - - /// - /// Double Data Rate Synchronous Dynamic Random-Access Memory - /// - DDR1, - - /// - /// Double Data Rate 2 Synchronous Dynamic Random-Access Memory - /// - DDR2, - - /// - /// Graphics Double Data Rate 2 Synchronous Dynamic Random-Access Memory - /// - GDDR2, - - /// - /// Graphics Double Data Rate 3 Synchronous Dynamic Random-Access Memory - /// - GDDR3, - - /// - /// Graphics Double Data Rate 4 Synchronous Dynamic Random-Access Memory - /// - GDDR4, - - /// - /// Double Data Rate 3 Synchronous Dynamic Random-Access Memory - /// - DDR3, - - /// - /// Graphics Double Data Rate 5 Synchronous Dynamic Random-Access Memory - /// - GDDR5, - - /// - /// Lowe Power Double Data Rate 2 Synchronous Dynamic Random-Access Memory - /// - LPDDR2, - - /// - /// Graphics Double Data Rate 5X Synchronous Dynamic Random-Access Memory - /// - GDDR5X - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GPUType.cs b/app/NvAPIWrapper/Native/GPU/GPUType.cs deleted file mode 100644 index 090f48d8..00000000 --- a/app/NvAPIWrapper/Native/GPU/GPUType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Possible GPU types - /// - public enum GPUType - { - /// - /// Unknown GPU type - /// - Unknown = 0, - - /// - /// Integrated GPU - /// - Integrated = 1, - - /// - /// Discrete GPU - /// - Discrete = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/GetPerformanceStatesInfoFlags.cs b/app/NvAPIWrapper/Native/GPU/GetPerformanceStatesInfoFlags.cs deleted file mode 100644 index 94ecf9b5..00000000 --- a/app/NvAPIWrapper/Native/GPU/GetPerformanceStatesInfoFlags.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains the flags used by the GPUApi.GetPerformanceStatesInfo() function - /// - [Flags] - public enum GetPerformanceStatesInfoFlags - { - /// - /// Current performance states settings - /// - Current = 0, - - /// - /// Default performance states settings - /// - Default = 1, - - /// - /// Maximum range of performance states values - /// - Maximum = 2, - - /// - /// Minimum range of performance states values - /// - Minimum = 4 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/I2CSpeed.cs b/app/NvAPIWrapper/Native/GPU/I2CSpeed.cs deleted file mode 100644 index 02369414..00000000 --- a/app/NvAPIWrapper/Native/GPU/I2CSpeed.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains possible I2C bus speed values in kHz - /// - public enum I2CSpeed : uint - { - /// - /// Current / Default frequency setting - /// - Default, - - /// - /// 3kHz - /// - I2C3KHz, - - /// - /// 10kHz - /// - I2C10KHz, - - /// - /// 33kHz - /// - I2C33KHz, - - /// - /// 100kHz - /// - I2C100KHz, - - /// - /// 200kHz - /// - I2C200KHz, - - /// - /// 400kHz - /// - I2C400KHz - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationAttribute.cs b/app/NvAPIWrapper/Native/GPU/IlluminationAttribute.cs deleted file mode 100644 index d2e1e6c1..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of valid illumination attributes - /// - public enum IlluminationAttribute : uint - { - /// - /// Logo brightness control - /// - LogoBrightness = 0, - - /// - /// SLI bridge brightness control - /// - SLIBrightness - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationDeviceType.cs b/app/NvAPIWrapper/Native/GPU/IlluminationDeviceType.cs deleted file mode 100644 index ec277cad..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationDeviceType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of valid illumination zone device types - /// - public enum IlluminationDeviceType : uint - { - /// - /// Invalid device type - /// - Invalid = 0, - - /// - /// MCUV10 device - /// - MCUV10 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationPiecewiseLinearCycleType.cs b/app/NvAPIWrapper/Native/GPU/IlluminationPiecewiseLinearCycleType.cs deleted file mode 100644 index 79bbb585..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationPiecewiseLinearCycleType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of valid cycle types for the piecewise linear control mode - /// - public enum IlluminationPiecewiseLinearCycleType : uint - { - /// - /// Half half cycle mode - /// - HalfHalf = 0, - - /// - /// Full half cycle mode - /// - FullHalf, - - /// - /// Full repeat cycle mode - /// - FullRepeat, - - /// - /// Invalid cycle mode - /// - Invalid = 0xFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlMode.cs b/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlMode.cs deleted file mode 100644 index 187f623b..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlMode.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of available illumination zone control modes - /// - [Flags] - public enum IlluminationZoneControlMode : uint - { - /// - /// manual RGB control - /// - ManualRGB = 0, - - /// - /// Piecewise linear RGB control - /// - PiecewiseLinearRGB, - - /// - /// Invalid control mode - /// - Invalid = 0xFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlValuesType.cs b/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlValuesType.cs deleted file mode 100644 index 4bcf0c47..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationZoneControlValuesType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of valid zone control value types to set or to retrieve - /// - public enum IlluminationZoneControlValuesType - { - /// - /// Currently active values - /// - CurrentlyActive = 0, - - /// - /// Default values - /// - Default = 1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationZoneLocation.cs b/app/NvAPIWrapper/Native/GPU/IlluminationZoneLocation.cs deleted file mode 100644 index c7f0cfdb..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationZoneLocation.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of possible illumination zone locations - /// - public enum IlluminationZoneLocation : uint - { - /// - /// Located on the top of GPU - /// - GPUTop = 0x00, - - /// - /// Located on the top of SLI bridge - /// - SLITop = 0x20, - - /// - /// Invalid zone location - /// - Invalid = 0xFFFFFFFF - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/IlluminationZoneType.cs b/app/NvAPIWrapper/Native/GPU/IlluminationZoneType.cs deleted file mode 100644 index c524b1e3..00000000 --- a/app/NvAPIWrapper/Native/GPU/IlluminationZoneType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains a list of valid illumination zone types - /// - public enum IlluminationZoneType : uint - { - /// - /// Invalid zone type - /// - Invalid = 0, - - /// - /// RGB zone - /// - RGB, - - /// - /// Fixed color zone - /// - FixedColor - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/MonitorConnectionType.cs b/app/NvAPIWrapper/Native/GPU/MonitorConnectionType.cs deleted file mode 100644 index 567dfae4..00000000 --- a/app/NvAPIWrapper/Native/GPU/MonitorConnectionType.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Monitor connection types. This is reserved for future use and clients should not rely on this information. - /// - public enum MonitorConnectionType - { - /// - /// Monitor not yet initialized - /// - Uninitialized = 0, - - /// - /// Connected through a VGA compatible connector - /// - VGA, - - /// - /// Connected through a Component compatible connector - /// - Component, - - /// - /// Connected through a SVideo compatible connector - /// - SVideo, - - /// - /// Connected through a HDMI compatible connector - /// - HDMI, - - /// - /// Connected through a LVDS compatible connector - /// - DVI, - - /// - /// Connected through a DisplayPort compatible connector - /// - LVDS, - - /// - /// Connected through a DisplayPort compatible connector - /// - DisplayPort, - - /// - /// Connected through a Composite compatible connector - /// - Composite, - - /// - /// Connection type unknown - /// - Unknown = -1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/OutputId.cs b/app/NvAPIWrapper/Native/GPU/OutputId.cs deleted file mode 100644 index 32fdda18..00000000 --- a/app/NvAPIWrapper/Native/GPU/OutputId.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// GPU output IDs are identifiers for the GPU outputs that drive display devices. The GPU output might or might not be - /// connected to a display, or be active. Each output is identified by a bit setting within a 32-bit unsigned integer. - /// A GPU output mask consists of a 32-bit integer with several bits set, identifying more than one output from the - /// same physical GPU. - /// - [Flags] - public enum OutputId : uint - { - /// - /// Invalid output if - /// - Invalid = 0, - - /// - /// Represents Output 1 - /// - Output1 = 1U, - - /// - /// Represents Output 2 - /// - Output2 = 1u << 1, - - /// - /// Represents Output 3 - /// - Output3 = 1u << 2, - - /// - /// Represents Output 4 - /// - Output4 = 1u << 3, - - /// - /// Represents Output 5 - /// - Output5 = 1u << 4, - - /// - /// Represents Output 6 - /// - Output6 = 1u << 5, - - /// - /// Represents Output 7 - /// - Output7 = 1u << 6, - - /// - /// Represents Output 8 - /// - Output8 = 1u << 7, - - /// - /// Represents Output 9 - /// - Output9 = 1u << 8, - - /// - /// Represents Output 10 - /// - Output10 = 1u << 9, - - /// - /// Represents Output 11 - /// - Output11 = 1u << 10, - - /// - /// Represents Output 12 - /// - Output12 = 1u << 11, - - /// - /// Represents Output 13 - /// - Output13 = 1u << 12, - - /// - /// Represents Output 14 - /// - Output14 = 1u << 13, - - /// - /// Represents Output 15 - /// - Output15 = 1u << 14, - - /// - /// Represents Output 16 - /// - Output16 = 1u << 15, - - /// - /// Represents Output 17 - /// - Output17 = 1u << 16, - - /// - /// Represents Output 18 - /// - Output18 = 1u << 17, - - /// - /// Represents Output 19 - /// - Output19 = 1u << 18, - - /// - /// Represents Output 20 - /// - Output20 = 1u << 19, - - /// - /// Represents Output 21 - /// - Output21 = 1u << 20, - - /// - /// Represents Output 22 - /// - Output22 = 1u << 21, - - /// - /// Represents Output 23 - /// - Output23 = 1u << 22, - - /// - /// Represents Output 24 - /// - Output24 = 1u << 23, - - /// - /// Represents Output 25 - /// - Output25 = 1u << 24, - - /// - /// Represents Output 26 - /// - Output26 = 1u << 25, - - /// - /// Represents Output 27 - /// - Output27 = 1u << 26, - - /// - /// Represents Output 28 - /// - Output28 = 1u << 27, - - /// - /// Represents Output 29 - /// - Output29 = 1u << 28, - - /// - /// Represents Output 30 - /// - Output30 = 1u << 29, - - /// - /// Represents Output 31 - /// - Output31 = 1u << 30, - - /// - /// Represents Output 32 - /// - Output32 = 1u << 31 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/OutputType.cs b/app/NvAPIWrapper/Native/GPU/OutputType.cs deleted file mode 100644 index 571ff3ce..00000000 --- a/app/NvAPIWrapper/Native/GPU/OutputType.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Connected output device types - /// - public enum OutputType : uint - { - /// - /// Unknown display device - /// - Unknown = 0, - - /// - /// CRT display device - /// - CRT = 1, - - /// - /// Digital Flat Panel display device - /// - DFP = 2, - - /// - /// TV display device - /// - TV = 3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PCIeGeneration.cs b/app/NvAPIWrapper/Native/GPU/PCIeGeneration.cs deleted file mode 100644 index e66cfe6f..00000000 --- a/app/NvAPIWrapper/Native/GPU/PCIeGeneration.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known PCI-e generations and versions - /// - public enum PCIeGeneration : uint - { - /// - /// PCI-e 1.0 - /// - PCIe1 = 0, - - /// - /// PCI-e 1.1 - /// - PCIe1Minor1, - - /// - /// PCI-e 2.0 - /// - PCIe2, - - /// - /// PCI-e 3.0 - /// - PCIe3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PerformanceDecreaseReason.cs b/app/NvAPIWrapper/Native/GPU/PerformanceDecreaseReason.cs deleted file mode 100644 index 9b8f8fe0..00000000 --- a/app/NvAPIWrapper/Native/GPU/PerformanceDecreaseReason.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list possible reasons for performance decrease - /// - public enum PerformanceDecreaseReason : uint - { - /// - /// No performance decrease - /// - None = 0, - - /// - /// Thermal protection performance decrease - /// - ThermalProtection = 0x00000001, - - /// - /// Power control performance decrease - /// - PowerControl = 0x00000002, - - /// - /// AC-BATT event performance decrease - /// - // ReSharper disable once InconsistentNaming - AC_BATT = 0x00000004, - - /// - /// API triggered performance decrease - /// - ApiTriggered = 0x00000008, - - /// - /// Insufficient performance decrease (Power Connector Missing) - /// - InsufficientPower = 0x00000010, - - /// - /// Unknown - /// - Unknown = 0x80000000 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PerformanceLimit.cs b/app/NvAPIWrapper/Native/GPU/PerformanceLimit.cs deleted file mode 100644 index 34512673..00000000 --- a/app/NvAPIWrapper/Native/GPU/PerformanceLimit.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known performance limitations - /// - [Flags] - public enum PerformanceLimit : uint - { - /// - /// No performance limitation - /// - None = 0, - - /// - /// Limited by power usage - /// - PowerLimit = 0b1, - - /// - /// Limited by temperature - /// - TemperatureLimit = 0b10, - - /// - /// Limited by voltage - /// - VoltageLimit = 0b100, - - /// - /// Unknown limitation - /// - Unknown8 = 0b1000, - - /// - /// Limited due to no load - /// - NoLoadLimit = 0b10000 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PerformanceStateId.cs b/app/NvAPIWrapper/Native/GPU/PerformanceStateId.cs deleted file mode 100644 index de13baa8..00000000 --- a/app/NvAPIWrapper/Native/GPU/PerformanceStateId.cs +++ /dev/null @@ -1,105 +0,0 @@ -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains the list of valid performance state identifications - /// - public enum PerformanceStateId : uint - { - /// - /// Performance state 0 (Maximum 3D Quality) - /// - P0_3DPerformance = 0, - - /// - /// Performance state 1 (Maximum 3D Quality) - /// - P1_3DPerformance, - - /// - /// Performance state 2 (Balanced Performance) - /// - // ReSharper disable once InconsistentNaming - P2_Balanced, - - /// - /// Performance state 3 (Balanced Performance) - /// - // ReSharper disable once InconsistentNaming - P3_Balanced, - - /// - /// Performance state 4 - /// - P4, - - /// - /// Performance state 5 - /// - P5, - - /// - /// Performance state 6 - /// - P6, - - /// - /// Performance state 7 - /// - P7, - - /// - /// Performance state 8 (HD Video Playback) - /// - // ReSharper disable once InconsistentNaming - P8_HDVideoPlayback, - - /// - /// Performance state 9 - /// - P9, - - /// - /// Performance state 10 (DVD Video Playback) - /// - // ReSharper disable once InconsistentNaming - P10_DVDPlayback, - - /// - /// Performance state 11 - /// - P11, - - /// - /// Performance state 12 (Idle - PowerSaving mode) - /// - // ReSharper disable once InconsistentNaming - P12_Idle, - - /// - /// Performance state 13 - /// - P13, - - /// - /// Performance state 14 - /// - P14, - - /// - /// Performance state 15 - /// - P15, - - /// - /// Undefined performance state - /// - Undefined = PerformanceStatesInfoV1.MaxPerformanceStates, - - /// - /// All performance states - /// - All - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PerformanceStates20ClockType.cs b/app/NvAPIWrapper/Native/GPU/PerformanceStates20ClockType.cs deleted file mode 100644 index 7ea986a2..00000000 --- a/app/NvAPIWrapper/Native/GPU/PerformanceStates20ClockType.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains valid clock frequency types - /// - public enum PerformanceStates20ClockType - { - /// - /// Single frequency clock - /// - Single = 0, - - /// - /// Variable frequency clock - /// - Range - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PerformanceVoltageDomain.cs b/app/NvAPIWrapper/Native/GPU/PerformanceVoltageDomain.cs deleted file mode 100644 index 1a6673cc..00000000 --- a/app/NvAPIWrapper/Native/GPU/PerformanceVoltageDomain.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains the list of possible voltage domains - /// - public enum PerformanceVoltageDomain : uint - { - /// - /// GPU Core - /// - Core = 0, - - /// - /// Undefined voltage domain - /// - Undefined = PerformanceStatesInfoV2.MaxPerformanceStateVoltages - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PowerTopologyDomain.cs b/app/NvAPIWrapper/Native/GPU/PowerTopologyDomain.cs deleted file mode 100644 index 6e96a220..00000000 --- a/app/NvAPIWrapper/Native/GPU/PowerTopologyDomain.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Holds a list of known power topology domain - /// - public enum PowerTopologyDomain : uint - { - /// - /// The GPU - /// - GPU = 0, - - /// - /// The GPU board - /// - Board - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/PublicClockDomain.cs b/app/NvAPIWrapper/Native/GPU/PublicClockDomain.cs deleted file mode 100644 index f97de009..00000000 --- a/app/NvAPIWrapper/Native/GPU/PublicClockDomain.cs +++ /dev/null @@ -1,35 +0,0 @@ -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Contains the list of clocks available to public - /// - public enum PublicClockDomain - { - /// - /// Undefined - /// - Undefined = ClockFrequenciesV1.MaxClocksPerGPU, - - /// - /// 3D graphics clock - /// - Graphics = 0, - - /// - /// Memory clock - /// - Memory = 4, - - /// - /// Processor clock - /// - Processor = 7, - - /// - /// Video decoding clock - /// - Video = 8 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/BoardInfo.cs b/app/NvAPIWrapper/Native/GPU/Structures/BoardInfo.cs deleted file mode 100644 index b30b2a23..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/BoardInfo.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds the board information (a unique GPU Board Serial Number) stored in the InfoROM - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct BoardInfo : IInitializable, IEquatable - { - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - internal byte[] _SerialNumber; - - /// - /// Board Serial Number - /// - public byte[] SerialNumber - { - get => _SerialNumber; - } - - /// - public bool Equals(BoardInfo other) - { - return _SerialNumber.SequenceEqual(other._SerialNumber); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is BoardInfo info && Equals(info); - } - - /// - public override int GetHashCode() - { - // ReSharper disable once NonReadonlyMemberInGetHashCode - return _SerialNumber?.GetHashCode() ?? 0; - } - - /// - public override string ToString() - { - return SerialNumber == null ? "Unknown" : "Serial " + BitConverter.ToString(SerialNumber); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(BoardInfo left, BoardInfo right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(BoardInfo left, BoardInfo right) - { - return !left.Equals(right); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ClockDomainInfo.cs b/app/NvAPIWrapper/Native/GPU/Structures/ClockDomainInfo.cs deleted file mode 100644 index 8a40d732..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ClockDomainInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the clock frequency of an specific clock domain - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ClockDomainInfo - { - internal readonly uint _IsPresent; - internal readonly uint _Frequency; - - /// - /// Gets a boolean value that indicates if this clock domain is present on this GPU and with the requested clock type. - /// - public bool IsPresent - { - get => _IsPresent.GetBit(0); - } - - /// - /// Gets the clock frequency in kHz - /// - public uint Frequency - { - get => _Frequency; - } - - /// - public override string ToString() - { - return IsPresent ? $"{_Frequency:N0} kHz" : "N/A"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV1.cs deleted file mode 100644 index c8abe0cf..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV1.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds clock frequencies currently associated with a physical GPU - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ClockFrequenciesV1 : IInitializable, IClockFrequencies - { - internal const int MaxClocksPerGPU = 32; - - internal StructureVersion _Version; - internal readonly uint _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxClocksPerGPU)] - internal ClockDomainInfo[] _Clocks; - - /// - public IReadOnlyDictionary Clocks - { - get => _Clocks - .Select((value, index) => new {index, value}) - .Where(arg => Enum.IsDefined(typeof(PublicClockDomain), arg.index)) - .ToDictionary(arg => (PublicClockDomain) arg.index, arg => arg.value); - } - - /// - public ClockType ClockType - { - get => ClockType.CurrentClock; - } - - /// - public ClockDomainInfo GraphicsClock - { - get => _Clocks[(int) PublicClockDomain.Graphics]; - } - - /// - public ClockDomainInfo MemoryClock - { - get => _Clocks[(int) PublicClockDomain.Memory]; - } - - /// - public ClockDomainInfo VideoDecodingClock - { - get => _Clocks[(int) PublicClockDomain.Video]; - } - - /// - public ClockDomainInfo ProcessorClock - { - get => _Clocks[(int) PublicClockDomain.Processor]; - } - - /// - public override string ToString() - { - return - $"[{ClockType}] 3D Graphics = {GraphicsClock} - Memory = {MemoryClock} - Video Decoding = {VideoDecodingClock} - Processor = {ProcessorClock}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV2.cs deleted file mode 100644 index f56c5f82..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV2.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds clock frequencies associated with a physical GPU and an specified clock type - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct ClockFrequenciesV2 : IInitializable, IClockFrequencies - { - internal const int MaxClocksPerGpu = 32; - - internal StructureVersion _Version; - internal readonly uint _ClockTypeAndReserve; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxClocksPerGpu)] - internal ClockDomainInfo[] _Clocks; - - /// - /// Creates a new ClockFrequenciesV2 - /// - /// The type of the clock frequency being requested - public ClockFrequenciesV2(ClockType clockType = ClockType.CurrentClock) - { - this = typeof(ClockFrequenciesV2).Instantiate(); - _ClockTypeAndReserve = 0u.SetBits(0, 2, (uint) clockType); - } - - /// - public IReadOnlyDictionary Clocks - { - get => _Clocks - .Select((value, index) => new {index, value}) - .Where(arg => Enum.IsDefined(typeof(PublicClockDomain), arg.index)) - .ToDictionary(arg => (PublicClockDomain) arg.index, arg => arg.value); - } - - /// - public ClockType ClockType - { - get => (ClockType) _ClockTypeAndReserve.GetBits(0, 2); - } - - /// - public ClockDomainInfo GraphicsClock - { - get => _Clocks[(int) PublicClockDomain.Graphics]; - } - - /// - public ClockDomainInfo MemoryClock - { - get => _Clocks[(int) PublicClockDomain.Memory]; - } - - /// - public ClockDomainInfo VideoDecodingClock - { - get => _Clocks[(int) PublicClockDomain.Video]; - } - - /// - public ClockDomainInfo ProcessorClock - { - get => _Clocks[(int) PublicClockDomain.Processor]; - } - - /// - public override string ToString() - { - return - $"[{ClockType}] 3D Graphics = {GraphicsClock} - Memory = {MemoryClock} - Video Decoding = {VideoDecodingClock} - Processor = {ProcessorClock}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV3.cs deleted file mode 100644 index 2f7c638c..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ClockFrequenciesV3.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds clock frequencies associated with a physical GPU and an specified clock type - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct ClockFrequenciesV3 : IInitializable, IClockFrequencies - { - internal const int MaxClocksPerGpu = 32; - - internal StructureVersion _Version; - internal readonly uint _ClockTypeAndReserve; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxClocksPerGpu)] - internal ClockDomainInfo[] _Clocks; - - /// - /// Creates a new ClockFrequenciesV3 - /// - /// The type of the clock frequency being requested - public ClockFrequenciesV3(ClockType clockType = ClockType.CurrentClock) - { - this = typeof(ClockFrequenciesV3).Instantiate(); - _ClockTypeAndReserve = 0u.SetBits(0, 2, (uint) clockType); - } - - /// - public IReadOnlyDictionary Clocks - { - get => _Clocks - .Select((value, index) => new {index, value}) - .Where(arg => Enum.IsDefined(typeof(PublicClockDomain), arg.index)) - .ToDictionary(arg => (PublicClockDomain) arg.index, arg => arg.value); - } - - /// - /// Gets the type of clock frequencies provided with this object - /// - public ClockType ClockType - { - get => (ClockType) _ClockTypeAndReserve.GetBits(0, 2); - } - - /// - public ClockDomainInfo GraphicsClock - { - get => _Clocks[(int) PublicClockDomain.Graphics]; - } - - /// - public ClockDomainInfo MemoryClock - { - get => _Clocks[(int) PublicClockDomain.Memory]; - } - - /// - public ClockDomainInfo VideoDecodingClock - { - get => _Clocks[(int) PublicClockDomain.Video]; - } - - /// - public ClockDomainInfo ProcessorClock - { - get => _Clocks[(int) PublicClockDomain.Processor]; - } - - /// - public override string ToString() - { - return - $"[{ClockType}] 3D Graphics = {GraphicsClock} - Memory = {MemoryClock} - Video Decoding = {VideoDecodingClock} - Processor = {ProcessorClock}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV1.cs deleted file mode 100644 index 8d1bc61a..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV1.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the system's display driver memory. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DisplayDriverMemoryInfoV1 : IInitializable, IDisplayDriverMemoryInfo - { - internal StructureVersion _Version; - internal readonly uint _DedicatedVideoMemory; - internal readonly uint _AvailableDedicatedVideoMemory; - internal readonly uint _SystemVideoMemory; - internal readonly uint _SharedSystemMemory; - - /// - public uint DedicatedVideoMemoryInkB - { - get => _DedicatedVideoMemory; - } - - /// - public uint AvailableDedicatedVideoMemoryInkB - { - get => _AvailableDedicatedVideoMemory; - } - - /// - public uint SystemVideoMemoryInkB - { - get => _SystemVideoMemory; - } - - /// - public uint SharedSystemMemoryInkB - { - get => _SharedSystemMemory; - } - - /// - public uint CurrentAvailableDedicatedVideoMemoryInkB - { - get => _AvailableDedicatedVideoMemory; - } - - /// - public override string ToString() - { - return $"{AvailableDedicatedVideoMemoryInkB / 1024} MB / {DedicatedVideoMemoryInkB / 1024} MB"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV2.cs deleted file mode 100644 index c01cc583..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV2.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the system's display driver memory. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct DisplayDriverMemoryInfoV2 : IInitializable, IDisplayDriverMemoryInfo - { - internal StructureVersion _Version; - internal readonly uint _DedicatedVideoMemory; - internal readonly uint _AvailableDedicatedVideoMemory; - internal readonly uint _SystemVideoMemory; - internal readonly uint _SharedSystemMemory; - internal readonly uint _CurrentAvailableDedicatedVideoMemory; - - /// - public uint DedicatedVideoMemoryInkB - { - get => _DedicatedVideoMemory; - } - - /// - public uint AvailableDedicatedVideoMemoryInkB - { - get => _AvailableDedicatedVideoMemory; - } - - /// - public uint SystemVideoMemoryInkB - { - get => _SystemVideoMemory; - } - - /// - public uint SharedSystemMemoryInkB - { - get => _SharedSystemMemory; - } - - /// - public uint CurrentAvailableDedicatedVideoMemoryInkB - { - get => _CurrentAvailableDedicatedVideoMemory; - } - - /// - public override string ToString() - { - return - $"{AvailableDedicatedVideoMemoryInkB / 1024} MB ({CurrentAvailableDedicatedVideoMemoryInkB / 1024} MB) / {DedicatedVideoMemoryInkB / 1024} MB"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV3.cs deleted file mode 100644 index 1d4f368f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/DisplayDriverMemoryInfoV3.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the system's display driver memory. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct DisplayDriverMemoryInfoV3 : IInitializable, IDisplayDriverMemoryInfo - { - internal StructureVersion _Version; - internal readonly uint _DedicatedVideoMemory; - internal readonly uint _AvailableDedicatedVideoMemory; - internal readonly uint _SystemVideoMemory; - internal readonly uint _SharedSystemMemory; - internal readonly uint _CurrentAvailableDedicatedVideoMemory; - internal readonly uint _DedicatedVideoMemoryEvictionsSize; - internal readonly uint _DedicatedVideoMemoryEvictionCount; - - /// - public uint DedicatedVideoMemoryInkB - { - get => _DedicatedVideoMemory; - } - - /// - public uint AvailableDedicatedVideoMemoryInkB - { - get => _AvailableDedicatedVideoMemory; - } - - /// - public uint SystemVideoMemoryInkB - { - get => _SystemVideoMemory; - } - - /// - public uint SharedSystemMemoryInkB - { - get => _SharedSystemMemory; - } - - /// - public uint CurrentAvailableDedicatedVideoMemoryInkB - { - get => _CurrentAvailableDedicatedVideoMemory; - } - - /// - /// Size(in kb) of the total size of memory released as a result of the evictions. - /// - public uint DedicatedVideoMemoryEvictionsSize - { - get => _DedicatedVideoMemoryEvictionsSize; - } - - /// - /// Indicates the number of eviction events that caused an allocation to be removed from dedicated video memory to free - /// GPU video memory to make room for other allocations. - /// - public uint DedicatedVideoMemoryEvictionCount - { - get => _DedicatedVideoMemoryEvictionCount; - } - - /// - public override string ToString() - { - return - $"{AvailableDedicatedVideoMemoryInkB / 1024} MB ({CurrentAvailableDedicatedVideoMemoryInkB / 1024} MB) / {DedicatedVideoMemoryInkB / 1024} MB"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/DisplayIdsV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/DisplayIdsV2.cs deleted file mode 100644 index b1e5c00a..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/DisplayIdsV2.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Represents a display identification and its attributes - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct DisplayIdsV2 : IInitializable, IDisplayIds, IEquatable - { - internal StructureVersion _Version; - internal readonly MonitorConnectionType _ConnectionType; - internal readonly uint _DisplayId; - internal readonly uint _RawReserved; - - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - public bool Equals(DisplayIdsV2 other) - { - return _DisplayId == other._DisplayId; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DisplayIdsV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - return (int) _DisplayId; - } - - /// - public MonitorConnectionType ConnectionType - { - get => _ConnectionType; - } - - /// - public bool IsDynamic - { - get => _RawReserved.GetBit(0); - } - - /// - public bool IsMultiStreamRootNode - { - get => _RawReserved.GetBit(1); - } - - /// - public bool IsActive - { - get => _RawReserved.GetBit(2); - } - - /// - public bool IsCluster - { - get => _RawReserved.GetBit(3); - } - - /// - public bool IsOSVisible - { - get => _RawReserved.GetBit(4); - } - - /// - public bool IsWFD - { - get => _RawReserved.GetBit(5); - } - - /// - public bool IsConnected - { - get => _RawReserved.GetBit(6); - } - - /// - public bool IsPhysicallyConnected - { - get => _RawReserved.GetBit(17); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/DynamicPerformanceStatesInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/DynamicPerformanceStatesInfoV1.cs deleted file mode 100644 index 1c5fcd0d..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/DynamicPerformanceStatesInfoV1.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the dynamic performance states (such as GPU utilization domain) - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DynamicPerformanceStatesInfoV1 : IInitializable, IUtilizationStatus - { - internal const int MaxGpuUtilizations = 8; - - internal StructureVersion _Version; - internal readonly uint _Flags; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxGpuUtilizations)] - internal UtilizationDomainInfo[] _UtilizationDomain; - - /// - /// Gets a boolean value indicating if the dynamic performance state is enabled - /// - public bool IsDynamicPerformanceStatesEnabled - { - get => _Flags.GetBit(0); - } - - /// - public Dictionary Domains - { - get => _UtilizationDomain - .Select((value, index) => new {index, value}) - .Where(arg => Enum.IsDefined(typeof(UtilizationDomain), arg.index) && arg.value.IsPresent) - .ToDictionary(arg => (UtilizationDomain) arg.index, arg => arg.value as IUtilizationDomainInfo); - } - - /// - public IUtilizationDomainInfo GPU - { - get => _UtilizationDomain[(int) UtilizationDomain.GPU]; - } - - /// - public IUtilizationDomainInfo FrameBuffer - { - get => _UtilizationDomain[(int) UtilizationDomain.FrameBuffer]; - } - - /// - public IUtilizationDomainInfo VideoEngine - { - get => _UtilizationDomain[(int) UtilizationDomain.VideoEngine]; - } - - /// - public IUtilizationDomainInfo BusInterface - { - get => _UtilizationDomain[(int) UtilizationDomain.BusInterface]; - } - - /// - public override string ToString() - { - return $"GPU = {GPU} - " + - $"FrameBuffer = {FrameBuffer} - " + - $"VideoEngine = {VideoEngine} - " + - $"BusInterface = {BusInterface}"; - } - - /// - /// Holds information about a dynamic performance state utilization domain - /// - [StructLayout(LayoutKind.Sequential)] - public struct UtilizationDomainInfo : IUtilizationDomainInfo - { - internal readonly uint _IsPresent; - internal readonly uint _Percentage; - - /// - public bool IsPresent - { - get => _IsPresent.GetBit(0); - } - - /// - public uint Percentage - { - get => _Percentage; - } - - /// - public override string ToString() - { - return IsPresent ? $"{Percentage}%" : "N/A"; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ECCConfigurationInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/ECCConfigurationInfoV1.cs deleted file mode 100644 index b45142d7..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ECCConfigurationInfoV1.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information about the ECC memory configurations - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ECCConfigurationInfoV1 : IInitializable - { - internal StructureVersion _Version; - internal uint _Flags; - - /// - /// Gets a boolean value indicating if the ECC memory is enabled - /// - public bool IsEnabled - { - get => _Flags.GetBit(0); - } - - /// - /// Gets a boolean value indicating if the ECC memory is enabled by default - /// - public bool IsEnabledByDefault - { - get => _Flags.GetBit(1); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ECCErrorInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/ECCErrorInfoV1.cs deleted file mode 100644 index 1f7980e3..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ECCErrorInfoV1.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding the ECC Memory errors - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ECCErrorInfoV1 : IInitializable - { - internal StructureVersion _Version; - internal ECCErrorInfo _CurrentErrors; - internal ECCErrorInfo _AggregatedErrors; - - /// - /// Gets the number of current errors - /// - public ECCErrorInfo CurrentErrors - { - get => _CurrentErrors; - } - - /// - /// Gets the number of aggregated errors - /// - public ECCErrorInfo AggregatedErrors - { - get => _AggregatedErrors; - } - - /// - /// Contains ECC memory error counters information - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ECCErrorInfo - { - internal ulong _SingleBitErrors; - internal ulong _DoubleBitErrors; - - /// - /// Gets the number of single bit errors - /// - public ulong SingleBitErrors - { - get => _SingleBitErrors; - } - - /// - /// Gets the number of double bit errors - /// - public ulong DoubleBitErrors - { - get => _DoubleBitErrors; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ECCStatusInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/ECCStatusInfoV1.cs deleted file mode 100644 index c023fd91..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ECCStatusInfoV1.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding the ECC Memory status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ECCStatusInfoV1 : IInitializable - { - internal StructureVersion _Version; - internal uint _IsSupported; - internal ECCConfiguration _ConfigurationOptions; - internal uint _IsEnabled; - - /// - /// Gets a boolean value indicating if the ECC memory is available and supported - /// - public bool IsSupported - { - get => _IsSupported.GetBit(0); - } - - /// - /// Gets the ECC memory configurations - /// - public ECCConfiguration ConfigurationOptions - { - get => _ConfigurationOptions; - } - - /// - /// Gets boolean value indicating if the ECC memory is currently enabled - /// - public bool IsEnabled - { - get => _IsEnabled.GetBit(0); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/EDIDV1.cs deleted file mode 100644 index 4984e887..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV1.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds whole or a part of the EDID information - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct EDIDV1 : IEDID, IInitializable - { - /// - /// The maximum number of data bytes that this structure can hold - /// - public const int MaxDataSize = 256; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDataSize)] - internal byte[] _Data; - - internal static EDIDV1 CreateWithData(byte[] data) - { - if (data.Length > MaxDataSize) - { - throw new ArgumentException("Data is too big.", nameof(data)); - } - - var edid = typeof(EDIDV1).Instantiate(); - Array.Copy(data, edid._Data, data.Length); - - return edid; - } - - /// - /// Gets whole or a part of the EDID data - /// - public byte[] Data - { - get => _Data; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/EDIDV2.cs deleted file mode 100644 index 28bf18ab..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV2.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds whole or a part of the EDID information - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct EDIDV2 : IEDID, IInitializable - { - /// - /// The maximum number of data bytes that this structure can hold - /// - public const int MaxDataSize = EDIDV1.MaxDataSize; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDataSize)] - internal byte[] _Data; - - internal uint _TotalSize; - - internal static EDIDV2 CreateWithData(byte[] data, int totalSize) - { - if (data.Length > MaxDataSize) - { - throw new ArgumentException("Data is too big.", nameof(data)); - } - - var edid = typeof(EDIDV2).Instantiate(); - edid._TotalSize = (uint) totalSize; - Array.Copy(data, 0, edid._Data, 0, totalSize); - - return edid; - } - - /// - /// Gets whole size of the EDID data - /// - public int TotalSize - { - get => (int) _TotalSize; - } - - /// - /// Gets whole or a part of the EDID data - /// - public byte[] Data - { - get => _Data.Take((int) Math.Min(_TotalSize, MaxDataSize)).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/EDIDV3.cs deleted file mode 100644 index 824eeeb8..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/EDIDV3.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds whole or a part of the EDID information - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct EDIDV3 : IEDID, IInitializable - { - /// - /// The maximum number of data bytes that this structure can hold - /// - public const int MaxDataSize = EDIDV1.MaxDataSize; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDataSize)] - internal byte[] _Data; - - internal uint _TotalSize; - internal uint _Identification; - internal uint _DataOffset; - - internal static EDIDV3 CreateWithOffset(uint id, uint offset) - { - var edid = typeof(EDIDV3).Instantiate(); - edid._Identification = id; - edid._DataOffset = offset; - - return edid; - } - - internal static EDIDV3 CreateWithData(uint id, uint offset, byte[] data, int totalSize) - { - if (data.Length > MaxDataSize) - { - throw new ArgumentException("Data is too big.", nameof(data)); - } - - var edid = typeof(EDIDV3).Instantiate(); - edid._Identification = id; - edid._DataOffset = offset; - edid._TotalSize = (uint) totalSize; - Array.Copy(data, 0, edid._Data, offset, totalSize); - - return edid; - } - - /// - /// Identification which always returned in a monotonically increasing counter. Across a split-EDID read we need to - /// verify that all calls returned the same value. This counter is incremented if we get the updated EDID. - /// - public int Identification - { - get => (int) _DataOffset; - } - - /// - /// Gets data offset of this part of EDID data. Which 256-byte page of the EDID we want to read. Start at 0. If the - /// read succeeds with TotalSize > MaxDataSize, call back again with offset+256 until we have read the entire buffer - /// - public int DataOffset - { - get => (int) _DataOffset; - } - - /// - /// Gets whole size of the EDID data - /// - public int TotalSize - { - get => (int) _TotalSize; - } - - /// - public byte[] Data - { - get => _Data.Take((int) Math.Min(_TotalSize - DataOffset, MaxDataSize)).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/GetIlluminationParameterV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/GetIlluminationParameterV1.cs deleted file mode 100644 index af7a5383..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/GetIlluminationParameterV1.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds necessary information to get an illumination attribute value - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct GetIlluminationParameterV1 : IInitializable - { - internal StructureVersion _Version; - internal PhysicalGPUHandle _GPUHandle; - internal IlluminationAttribute _Attribute; - internal uint _ValueInPercentage; - - /// - /// Creates a new instance of . - /// - /// The physical gpu handle. - /// The attribute. - public GetIlluminationParameterV1(PhysicalGPUHandle gpuHandle, IlluminationAttribute attribute) - { - this = typeof(GetIlluminationParameterV1).Instantiate(); - _GPUHandle = gpuHandle; - _Attribute = attribute; - } - - /// - /// Gets the parameter physical gpu handle - /// - public PhysicalGPUHandle PhysicalGPUHandle - { - get => _GPUHandle; - } - - /// - /// Gets the parameter attribute - /// - public IlluminationAttribute Attribute - { - get => _Attribute; - } - - /// - /// Gets the parameter value in percentage - /// - public uint ValueInPercentage - { - get => _ValueInPercentage; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV2.cs deleted file mode 100644 index 6c6602cc..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV2.cs +++ /dev/null @@ -1,240 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct I2CInfoV2 : IInitializable, IDisposable, II2CInfo - { - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly StructureVersion _Version; - private readonly OutputId _OutputMask; - private readonly byte _UseDDCPort; - private readonly byte _I2CDeviceAddress; - private ValueTypeArray _I2CRegisterAddress; - private readonly uint _I2CRegisterAddressLength; - private ValueTypeArray _Data; - private readonly uint _DataLength; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly uint _I2CSpeed; - private readonly I2CSpeed _I2CSpeedInKHz; - - /// - // ReSharper disable once ConvertToAutoProperty - public OutputId OutputMask - { - get => _OutputMask; - } - - /// - public bool UseDDCPort - { - get => _UseDDCPort > 0; - } - - - /// - // ReSharper disable once ConvertToAutoProperty - public I2CSpeed Speed - { - get => _I2CSpeedInKHz; - } - - /// - public bool IsReadOperation - { - get => (_I2CDeviceAddress & 1) == 1; - } - - /// - public byte DeviceAddress - { - get => (byte) (_I2CDeviceAddress >> 1); - } - - /// - public byte[] Data - { - get - { - if (_Data.IsNull || _DataLength == 0) - { - return new byte[0]; - } - - return _Data.ToArray((int) _DataLength); - } - } - - /// - public byte[] RegisterAddress - { - get - { - if (_I2CRegisterAddress.IsNull || _I2CRegisterAddressLength == 0) - { - return new byte[0]; - } - - return _I2CRegisterAddress.ToArray((int) _I2CRegisterAddressLength); - } - } - - /// - public byte? PortId - { - get => null; - } - - /// - /// Creates an instance of for write operations. - /// - /// The target display output mask - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The payload data - /// The target speed of the transaction in kHz - public I2CInfoV2( - OutputId outputMask, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - byte[] data, - I2CSpeed speed = I2CSpeed.Default - ) : this(outputMask, useDDCPort, deviceAddress, false, registerAddress, data, speed) - { - } - - /// - /// Creates an instance of for read operations. - /// - /// The target display output mask - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The length of the buffer to allocate for the read operation. - /// The target speed of the transaction in kHz - public I2CInfoV2( - OutputId outputMask, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - uint readDataLength, - I2CSpeed speed = I2CSpeed.Default - ) : this(outputMask, useDDCPort, deviceAddress, true, registerAddress, new byte[readDataLength], speed) - { - } - - private I2CInfoV2( - OutputId outputMask, - bool useDDCPort, - byte deviceAddress, - bool isRead, - byte[] registerAddress, - byte[] data, - I2CSpeed speed = I2CSpeed.Default - ) - { - this = typeof(I2CInfoV2).Instantiate(); - - _UseDDCPort = useDDCPort ? (byte) 1 : (byte) 0; - _OutputMask = outputMask; - _I2CDeviceAddress = (byte) (deviceAddress << 1); - _I2CSpeed = 0xFFFF; // Deprecated - _I2CSpeedInKHz = speed; - - if (isRead) - { - _I2CDeviceAddress |= 1; - } - - if (registerAddress?.Length > 0) - { - _I2CRegisterAddress = ValueTypeArray.FromArray(registerAddress); - _I2CRegisterAddressLength = (uint) registerAddress.Length; - } - else - { - _I2CRegisterAddress = ValueTypeArray.Null; - _I2CRegisterAddressLength = 0; - } - - if (data?.Length > 0) - { - _Data = ValueTypeArray.FromArray(data); - _DataLength = (uint) data.Length; - } - else - { - _Data = ValueTypeArray.Null; - _DataLength = 0; - } - } - - /// - /// Calculates and fills the last byte of data to the checksum value required by the DDCCI protocol - /// - /// The target device address. - /// The target register address. - /// The data to be sent and store the checksum. - public static void FillDDCCIChecksum(byte deviceAddress, byte[] registerAddress, byte[] data) - { - var checksum = deviceAddress; - - if (data == null) - { - throw new ArgumentNullException(nameof(data)); - } - - if (data.Length == 0) - { - throw new ArgumentException("Checksum needs at least one free byte.", nameof(data)); - } - - if (registerAddress == null) - { - throw new ArgumentNullException(nameof(registerAddress)); - } - - // ReSharper disable once ForCanBeConvertedToForeach - // ReSharper disable once LoopCanBeConvertedToQuery - for (var i = 0; i < registerAddress.Length; i++) - { - checksum ^= registerAddress[i]; - } - - // ReSharper disable once ForCanBeConvertedToForeach - // ReSharper disable once LoopCanBeConvertedToQuery - for (var i = 0; i < data.Length - 1; i++) - { - checksum ^= data[i]; - } - - data[data.Length - 1] = checksum; - } - - /// - public void Dispose() - { - if (!_I2CRegisterAddress.IsNull) - { - _I2CRegisterAddress.Dispose(); - } - - if (!_Data.IsNull) - { - _Data.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV3.cs deleted file mode 100644 index e62b6772..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/I2CInfoV3.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct I2CInfoV3 : IInitializable, IDisposable, II2CInfo - { - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly StructureVersion _Version; - private readonly OutputId _OutputMask; - private readonly byte _UseDDCPort; - private readonly byte _I2CDeviceAddress; - private ValueTypeArray _I2CRegisterAddress; - private readonly uint _I2CRegisterAddressLength; - private ValueTypeArray _Data; - private readonly uint _DataLength; - - // ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable - private readonly uint _I2CSpeed; - private readonly I2CSpeed _I2CSpeedInKHz; - private readonly byte _PortId; - private readonly uint _IsPortIdPresent; - - /// - // ReSharper disable once ConvertToAutoProperty - public OutputId OutputMask - { - get => _OutputMask; - } - - /// - public bool UseDDCPort - { - get => _UseDDCPort > 0; - } - - /// - // ReSharper disable once ConvertToAutoProperty - public I2CSpeed Speed - { - get => _I2CSpeedInKHz; - } - - /// - public bool IsReadOperation - { - get => (_I2CDeviceAddress & 1) == 1; - } - - /// - public byte DeviceAddress - { - get => (byte) (_I2CDeviceAddress >> 1); - } - - /// - public byte? PortId - { - get - { - if (_IsPortIdPresent > 0) - { - return _PortId; - } - - return null; - } - } - - /// - public byte[] Data - { - get - { - if (_Data.IsNull || _DataLength == 0) - { - return new byte[0]; - } - - return _Data.ToArray((int) _DataLength); - } - } - - /// - public byte[] RegisterAddress - { - get - { - if (_I2CRegisterAddress.IsNull || _I2CRegisterAddressLength == 0) - { - return new byte[0]; - } - - return _I2CRegisterAddress.ToArray((int) _I2CRegisterAddressLength); - } - } - - /// - /// Creates an instance of for write operations. - /// - /// The target display output mask - /// The port id on which device is connected - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The payload data - /// The target speed of the transaction in kHz - public I2CInfoV3( - OutputId outputMask, - byte? portId, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - byte[] data, - I2CSpeed speed = I2CSpeed.Default - ) : this(outputMask, portId, useDDCPort, deviceAddress, false, registerAddress, data, speed) - { - } - - /// - /// Creates an instance of for read operations. - /// - /// The target display output mask - /// The port id on which device is connected - /// A boolean value indicating that the DDC port should be used instead of the communication port - /// The device I2C slave address - /// The target I2C register address - /// The length of the buffer to allocate for the read operation. - /// The target speed of the transaction in kHz - public I2CInfoV3( - OutputId outputMask, - byte? portId, - bool useDDCPort, - byte deviceAddress, - byte[] registerAddress, - uint readDataLength, - I2CSpeed speed = I2CSpeed.Default - ) : this(outputMask, portId, useDDCPort, deviceAddress, true, registerAddress, new byte[readDataLength], speed) - { - } - - private I2CInfoV3( - OutputId outputMask, - byte? portId, - bool useDDCPort, - byte deviceAddress, - bool isRead, - byte[] registerAddress, - byte[] data, - I2CSpeed speed = I2CSpeed.Default - ) - { - this = typeof(I2CInfoV3).Instantiate(); - - _UseDDCPort = useDDCPort ? (byte) 1 : (byte) 0; - _OutputMask = outputMask; - _I2CDeviceAddress = (byte) (deviceAddress << 1); - _I2CSpeed = 0xFFFF; // Deprecated - _I2CSpeedInKHz = speed; - - if (isRead) - { - _I2CDeviceAddress |= 1; - } - - if (portId != null) - { - _PortId = portId.Value; - _IsPortIdPresent = 1; - } - else - { - _IsPortIdPresent = 0; - } - - if (registerAddress?.Length > 0) - { - _I2CRegisterAddress = ValueTypeArray.FromArray(registerAddress); - _I2CRegisterAddressLength = (uint) registerAddress.Length; - } - else - { - _I2CRegisterAddress = ValueTypeArray.Null; - _I2CRegisterAddressLength = 0; - } - - if (data?.Length > 0) - { - _Data = ValueTypeArray.FromArray(data); - _DataLength = (uint) data.Length; - } - else - { - _Data = ValueTypeArray.Null; - _DataLength = 0; - } - } - - /// - /// Calculates and fills the last byte of data to the checksum value required by the DDCCI protocol - /// - /// The target device address. - /// The target register address. - /// The data to be sent and store the checksum. - public static void FillDDCCIChecksum(byte deviceAddress, byte[] registerAddress, byte[] data) - { - I2CInfoV2.FillDDCCIChecksum(deviceAddress, registerAddress, data); - } - - /// - public void Dispose() - { - if (!_I2CRegisterAddress.IsNull) - { - _I2CRegisterAddress.Dispose(); - } - - if (!_Data.IsNull) - { - _Data.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlParametersV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlParametersV1.cs deleted file mode 100644 index cb22208f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlParametersV1.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding available devices illumination settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct IlluminationDeviceControlParametersV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - private const int MaximumNumberOfDevices = 32; - internal StructureVersion _Version; - internal uint _NumberOfDevices; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDevices)] - internal IlluminationDeviceControlV1[] _Devices; - - /// - /// Creates a new instance of . - /// - /// The list of illumination settings of devices. - public IlluminationDeviceControlParametersV1(IlluminationDeviceControlV1[] devices) - { - if (!(devices?.Length > 0) || devices.Length > MaximumNumberOfDevices) - { - throw new ArgumentOutOfRangeException(nameof(devices)); - } - - this = typeof(IlluminationDeviceControlParametersV1).Instantiate(); - _NumberOfDevices = (uint) devices.Length; - Array.Copy(devices, 0, _Devices, 0, devices.Length); - } - - /// - /// Gets a list of available illumination settings of devices. - /// - public IlluminationDeviceControlV1[] Devices - { - get => _Devices.Take((int) _NumberOfDevices).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlV1.cs deleted file mode 100644 index e4955f7e..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceControlV1.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a device illumination settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct IlluminationDeviceControlV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - internal IlluminationDeviceType _DeviceType; - internal IlluminationDeviceSyncV1 _SyncInformation; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - /// - /// Creates a new instance of . - /// - /// The device type. - /// The device sync information. - public IlluminationDeviceControlV1(IlluminationDeviceType deviceType, IlluminationDeviceSyncV1 syncInformation) - { - this = typeof(IlluminationDeviceControlV1).Instantiate(); - _DeviceType = deviceType; - _SyncInformation = syncInformation; - } - - /// - /// Gets the illumination device type - /// - public IlluminationDeviceType DeviceType - { - get => _DeviceType; - } - - /// - /// Gets the illumination synchronization information - /// - public IlluminationDeviceSyncV1 SyncInformation - { - get => _SyncInformation; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoParametersV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoParametersV1.cs deleted file mode 100644 index 728c3735..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoParametersV1.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding available illumination devices - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct IlluminationDeviceInfoParametersV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - private const int MaximumNumberOfDevices = 32; - internal StructureVersion _Version; - internal uint _NumberOfDevices; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDevices)] - internal IlluminationDeviceInfoV1[] _Devices; - - /// - /// Gets an array containing all available illumination devices - /// - public IlluminationDeviceInfoV1[] Devices - { - get => _Devices.Take((int) _NumberOfDevices).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoV1.cs deleted file mode 100644 index 222c58a3..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceInfoV1.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a illumination device - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationDeviceInfoV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - private const int MaximumNumberOfDeviceData = 64; - internal IlluminationDeviceType _DeviceType; - internal IlluminationZoneControlMode _ControlModes; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDeviceData)] - internal byte[] _DeviceData; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - /// - /// Gets the illumination device type - /// - public IlluminationDeviceType DeviceType - { - get => _DeviceType; - } - - /// - /// Gets the illumination device control mode - /// - public IlluminationZoneControlMode ControlMode - { - get => _ControlModes; - } - - /// - /// Gets the I2C index for a MCUV10 device - /// - /// Device type is not MCUV10. - public byte MCUV10DeviceI2CIndex - { - get - { - if (DeviceType != IlluminationDeviceType.MCUV10) - { - throw new InvalidOperationException("Device type is not MCUV10."); - } - - return _DeviceData[0]; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceSyncV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceSyncV1.cs deleted file mode 100644 index 69606bb0..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationDeviceSyncV1.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding the data necessary for synchronization. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationDeviceSyncV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - internal byte _IsSync; - internal ulong _TimeStampInMS; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - /// - /// Creates a new instance of - /// - /// A boolean value indicating if synchronization is enabled. - /// The synchronization timestamp in ms - public IlluminationDeviceSyncV1(bool isSync, ulong timeStampInMS) - { - this = typeof(IlluminationDeviceSyncV1).Instantiate(); - _IsSync = isSync ? (byte) 1 : (byte) 0; - _TimeStampInMS = timeStampInMS; - } - - /// - /// Gets a boolean value indicating the need for synchronization. - /// - public bool IsSync - { - get => _IsSync > 0; - } - - /// - /// Gets the timestamp in milliseconds required for synchronization. - /// - public ulong TimeStampInMS - { - get => _TimeStampInMS; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColor.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColor.cs deleted file mode 100644 index a35a461c..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColor.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a fixed color control data - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataFixedColor : IInitializable - { - private const int MaximumNumberOfDataBytes = 64; - private const int MaximumNumberOfReservedBytes = 64; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDataBytes)] - internal byte[] _Data; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReservedBytes)] - internal byte[] _Reserved; - - /// - /// Creates a new instance of . - /// - /// The zone manual control data. - public IlluminationZoneControlDataFixedColor(IlluminationZoneControlDataManualFixedColor manualFixedColor) - : this(manualFixedColor.ToByteArray()) - { - } - - /// - /// Creates a new instance of . - /// - /// The zone piecewise linear control data. - public IlluminationZoneControlDataFixedColor( - IlluminationZoneControlDataPiecewiseLinearFixedColor piecewiseLinearFixedColor) - : this(piecewiseLinearFixedColor.ToByteArray()) - { - } - - private IlluminationZoneControlDataFixedColor(byte[] data) - { - if (!(data?.Length > 0) || data.Length > MaximumNumberOfDataBytes) - { - throw new ArgumentOutOfRangeException(nameof(data)); - } - - this = typeof(IlluminationZoneControlDataFixedColor).Instantiate(); - Array.Copy(data, 0, _Data, 0, data.Length); - } - - /// - /// Gets the control data as a manual control structure. - /// - /// An instance of containing manual settings. - public IlluminationZoneControlDataManualFixedColor AsManual() - { - return _Data.ToStructure(); - } - - /// - /// Gets the control data as a piecewise linear control structure. - /// - /// - /// An instance of containing piecewise - /// settings. - /// - public IlluminationZoneControlDataPiecewiseLinearFixedColor AsPiecewise() - { - return _Data.ToStructure(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColorParameters.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColorParameters.cs deleted file mode 100644 index efd45fbc..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataFixedColorParameters.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a fixed color - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataFixedColorParameters - { - internal byte _BrightnessInPercentage; - - /// - /// Creates a new instance of . - /// - /// The brightness percentage value of the zone. - public IlluminationZoneControlDataFixedColorParameters(byte brightnessInPercentage) - { - _BrightnessInPercentage = brightnessInPercentage; - } - - /// - /// Gets the brightness percentage value of the zone. - /// - public byte BrightnessInPercentage - { - get => _BrightnessInPercentage; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualFixedColor.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualFixedColor.cs deleted file mode 100644 index 87fac353..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualFixedColor.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a manual fixed color control method - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataManualFixedColor : IInitializable - { - internal IlluminationZoneControlDataFixedColorParameters _Parameters; - - /// - /// Creates a new instance of . - /// - /// The fixed color parameters. - public IlluminationZoneControlDataManualFixedColor(IlluminationZoneControlDataFixedColorParameters parameters) - { - _Parameters = parameters; - } - - /// - /// Gets the fixed color parameters - /// - internal IlluminationZoneControlDataFixedColorParameters Parameters - { - get => _Parameters; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGB.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGB.cs deleted file mode 100644 index 26e582f9..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGB.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a RGB control method - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataManualRGB : IInitializable - { - internal IlluminationZoneControlDataManualRGBParameters _Parameters; - - /// - /// Creates a new instance of . - /// - /// The RGB parameters. - public IlluminationZoneControlDataManualRGB(IlluminationZoneControlDataManualRGBParameters parameters) - { - _Parameters = parameters; - } - - /// - /// Gets the RGB parameters - /// - public IlluminationZoneControlDataManualRGBParameters Parameters - { - get => _Parameters; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGBParameters.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGBParameters.cs deleted file mode 100644 index 4a136232..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataManualRGBParameters.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a RGB color - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataManualRGBParameters - { - internal byte _Red; - internal byte _Green; - internal byte _Blue; - internal byte _BrightnessInPercentage; - - /// - /// Creates a new instance of . - /// - /// The red component of color applied to the zone. - /// The green component of color applied to the zone. - /// The blue component of color applied to the zone. - /// The brightness percentage value of the zone. - // ReSharper disable once TooManyDependencies - public IlluminationZoneControlDataManualRGBParameters( - byte red, - byte green, - byte blue, - byte brightnessInPercentage) - { - _Red = red; - _Green = green; - _Blue = blue; - _BrightnessInPercentage = brightnessInPercentage; - } - - /// - /// Gets the red component of color applied to the zone. - /// - public byte Red - { - get => _Red; - } - - /// - /// Gets the green component of color applied to the zone. - /// - public byte Green - { - get => _Green; - } - - /// - /// Gets the blue component of color applied to the zone. - /// - public byte Blue - { - get => _Blue; - } - - /// - /// Gets the brightness percentage value of the zone. - /// - public byte BrightnessInPercentage - { - get => _BrightnessInPercentage; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinear.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinear.cs deleted file mode 100644 index 16106eed..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinear.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a piecewise linear function settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataPiecewiseLinear - { - internal IlluminationPiecewiseLinearCycleType _CycleType; - internal byte _GroupPeriodRepeatCount; - internal ushort _RiseDurationInMS; - internal ushort _FallDurationInMS; - internal ushort _ADurationInMS; - internal ushort _BDurationInMS; - internal ushort _NextGroupIdleDurationInMS; - internal ushort _PhaseOffsetInMS; - - /// - /// Creates a new instance of . - /// - /// The type of cycle effect to apply. - /// The number of times to repeat function within group period. - /// The time in millisecond to transition from color A to color B. - /// The time in millisecond to transition from color B to color A. - /// The time in millisecond to remain at color A before color A to color B transition. - /// The time in millisecond to remain at color B before color B to color A transition. - /// - /// The time in millisecond to remain idle before next group of repeated function - /// cycles. - /// - /// The time in millisecond to offset the cycle relative to other zones. - // ReSharper disable once TooManyDependencies - public IlluminationZoneControlDataPiecewiseLinear( - IlluminationPiecewiseLinearCycleType cycleType, - byte groupPeriodRepeatCount, - ushort riseDurationInMS, - ushort fallDurationInMS, - ushort aDurationInMS, - ushort bDurationInMS, - ushort nextGroupIdleDurationInMS, - ushort phaseOffsetInMS) - { - _CycleType = cycleType; - _GroupPeriodRepeatCount = groupPeriodRepeatCount; - _RiseDurationInMS = riseDurationInMS; - _FallDurationInMS = fallDurationInMS; - _ADurationInMS = aDurationInMS; - _BDurationInMS = bDurationInMS; - _NextGroupIdleDurationInMS = nextGroupIdleDurationInMS; - _PhaseOffsetInMS = phaseOffsetInMS; - } - - /// - /// Gets the time in millisecond to offset the cycle relative to other zones. - /// - public ushort PhaseOffsetInMS - { - get => _PhaseOffsetInMS; - } - - /// - /// Gets the time in millisecond to remain idle before next group of repeated function cycles. - /// - public ushort NextGroupIdleDurationInMS - { - get => _NextGroupIdleDurationInMS; - } - - /// - /// Gets the time in millisecond to remain at color B before color B to color A transition. - /// - public ushort BDurationInMS - { - get => _BDurationInMS; - } - - /// - /// Gets the time in millisecond to remain at color A before color A to color B transition. - /// - public ushort ADurationInMS - { - get => _ADurationInMS; - } - - /// - /// Gets the time in millisecond to transition from color B to color A. - /// - public ushort FallDurationInMS - { - get => _FallDurationInMS; - } - - /// - /// Gets the time in millisecond to transition from color A to color B. - /// - public ushort RiseDurationInMS - { - get => _RiseDurationInMS; - } - - /// - /// Gets the number of times to repeat function within group period. - /// - public byte GroupPeriodRepeatCount - { - get => _GroupPeriodRepeatCount; - } - - /// - /// Gets the type of cycle effect to apply. - /// - public IlluminationPiecewiseLinearCycleType CycleType - { - get => _CycleType; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearFixedColor.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearFixedColor.cs deleted file mode 100644 index 6d6570b6..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearFixedColor.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a piecewise linear fixed color control method - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataPiecewiseLinearFixedColor : IInitializable - { - private const int NumberColorEndPoints = 2; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NumberColorEndPoints)] - internal IlluminationZoneControlDataFixedColorParameters[] _EndPoints; - - internal IlluminationZoneControlDataPiecewiseLinear _PiecewiseLinearData; - - /// - /// Creates a new instance of . - /// - /// The list of fixed color piecewise function endpoints. - /// The piecewise function settings. - public IlluminationZoneControlDataPiecewiseLinearFixedColor( - IlluminationZoneControlDataFixedColorParameters[] endPoints, - IlluminationZoneControlDataPiecewiseLinear piecewiseLinearData) - { - if (endPoints?.Length != NumberColorEndPoints) - { - throw new ArgumentOutOfRangeException(nameof(endPoints)); - } - - this = typeof(IlluminationZoneControlDataPiecewiseLinearFixedColor) - .Instantiate(); - _PiecewiseLinearData = piecewiseLinearData; - Array.Copy(endPoints, 0, _EndPoints, 0, endPoints.Length); - } - - /// - /// Gets the piecewise function settings - /// - public IlluminationZoneControlDataPiecewiseLinear PiecewiseLinearData - { - get => _PiecewiseLinearData; - } - - /// - /// Gets the list of fixed color piecewise function endpoints - /// - public IlluminationZoneControlDataFixedColorParameters[] EndPoints - { - get => _EndPoints; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearRGB.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearRGB.cs deleted file mode 100644 index 67f6b4bf..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataPiecewiseLinearRGB.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a piecewise linear RGB control method - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataPiecewiseLinearRGB : IInitializable - { - private const int NumberColorEndPoints = 2; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = NumberColorEndPoints)] - internal IlluminationZoneControlDataManualRGBParameters[] _EndPoints; - - internal IlluminationZoneControlDataPiecewiseLinear _PiecewiseLinearData; - - /// - /// Creates a new instance of . - /// - /// The list of RGB piecewise function endpoints. - /// The piecewise function settings. - public IlluminationZoneControlDataPiecewiseLinearRGB( - IlluminationZoneControlDataManualRGBParameters[] endPoints, - IlluminationZoneControlDataPiecewiseLinear piecewiseLinearData) - { - if (endPoints?.Length != NumberColorEndPoints) - { - throw new ArgumentOutOfRangeException(nameof(endPoints)); - } - - this = typeof(IlluminationZoneControlDataPiecewiseLinearRGB) - .Instantiate(); - _PiecewiseLinearData = piecewiseLinearData; - Array.Copy(endPoints, 0, _EndPoints, 0, endPoints.Length); - } - - /// - /// Gets the piecewise function settings - /// - public IlluminationZoneControlDataPiecewiseLinear PiecewiseLinearData - { - get => _PiecewiseLinearData; - } - - /// - /// Gets the list of RGB function endpoints - /// - public IlluminationZoneControlDataManualRGBParameters[] EndPoints - { - get => _EndPoints; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataRGB.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataRGB.cs deleted file mode 100644 index 033b3736..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlDataRGB.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a RGB control data - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlDataRGB : IInitializable - { - private const int MaximumNumberOfDataBytes = 64; - private const int MaximumNumberOfReservedBytes = 64; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDataBytes)] - internal byte[] _Data; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReservedBytes)] - internal byte[] _Reserved; - - /// - /// Creates a new instance of . - /// - /// The zone manual control data. - public IlluminationZoneControlDataRGB(IlluminationZoneControlDataManualRGB manualRGB) - : this(manualRGB.ToByteArray()) - { - } - - /// - /// Creates a new instance of . - /// - /// The zone piecewise linear control data. - public IlluminationZoneControlDataRGB(IlluminationZoneControlDataPiecewiseLinearRGB piecewiseLinearRGB) - : this(piecewiseLinearRGB.ToByteArray()) - { - } - - private IlluminationZoneControlDataRGB(byte[] data) - { - if (!(data?.Length > 0) || data.Length > MaximumNumberOfDataBytes) - { - throw new ArgumentOutOfRangeException(nameof(data)); - } - - this = typeof(IlluminationZoneControlDataRGB).Instantiate(); - Array.Copy(data, 0, _Data, 0, data.Length); - } - - /// - /// Gets the control data as a manual control structure. - /// - /// An instance of containing manual settings. - public IlluminationZoneControlDataManualRGB AsManual() - { - return _Data.ToStructure(); - } - - /// - /// Gets the control data as a piecewise linear control structure. - /// - /// - /// An instance of containing piecewise linear - /// settings. - /// - public IlluminationZoneControlDataPiecewiseLinearRGB AsPiecewise() - { - return _Data.ToStructure(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlParametersV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlParametersV1.cs deleted file mode 100644 index 193e8e20..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlParametersV1.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding available zone control settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct IlluminationZoneControlParametersV1 : IInitializable - { - private const int MaximumNumberOfZoneControls = 32; - private const int MaximumNumberOfReservedBytes = 64; - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfZoneControls; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReservedBytes)] - internal byte[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfZoneControls)] - internal IlluminationZoneControlV1[] _ZoneControls; - - /// - /// Creates a new instance of . - /// - /// The type of settings to represents. - public IlluminationZoneControlParametersV1(IlluminationZoneControlValuesType valuesType) - { - this = typeof(IlluminationZoneControlParametersV1).Instantiate(); - _Flags.SetBit(0, valuesType == IlluminationZoneControlValuesType.Default); - } - - /// - /// Creates a new instance of . - /// - /// The type of settings to represents. - /// An array of zone control settings. - public IlluminationZoneControlParametersV1( - IlluminationZoneControlValuesType valuesType, - IlluminationZoneControlV1[] zoneControls) : this(valuesType) - { - if (!(zoneControls?.Length > 0) || zoneControls.Length > MaximumNumberOfZoneControls) - { - throw new ArgumentOutOfRangeException(nameof(valuesType)); - } - - _NumberOfZoneControls = (uint) zoneControls.Length; - Array.Copy(zoneControls, 0, _ZoneControls, 0, zoneControls.Length); - } - - /// - /// Gets the type of settings to represents. - /// - public IlluminationZoneControlValuesType ValuesType - { - get => _Flags.GetBit(0) - ? IlluminationZoneControlValuesType.Default - : IlluminationZoneControlValuesType.CurrentlyActive; - } - - /// - /// Gets an array of zone control settings - /// - public IlluminationZoneControlV1[] ZoneControls - { - get => _ZoneControls.Take((int) _NumberOfZoneControls).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlV1.cs deleted file mode 100644 index 9509ff81..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneControlV1.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a zone control status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneControlV1 : IInitializable - { - private const int MaximumNumberOfDataBytes = 128; - private const int MaximumNumberOfReservedBytes = 64; - - internal IlluminationZoneType _ZoneType; - - internal IlluminationZoneControlMode _ControlMode; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDataBytes)] - internal byte[] _Data; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReservedBytes)] - internal byte[] _Reserved; - - /// - /// Creates a new instance of . - /// - /// The zone control mode. - /// The zone control RGB data. - public IlluminationZoneControlV1( - IlluminationZoneControlMode controlMode, - IlluminationZoneControlDataRGB rgbData) - : this(controlMode, IlluminationZoneType.RGB, rgbData.ToByteArray()) - { - } - - /// - /// Creates a new instance of . - /// - /// The zone control mode. - /// The zone control fixed color data. - public IlluminationZoneControlV1( - IlluminationZoneControlMode controlMode, - IlluminationZoneControlDataFixedColor fixedColorData) - : this(controlMode, IlluminationZoneType.FixedColor, fixedColorData.ToByteArray()) - { - } - - private IlluminationZoneControlV1( - IlluminationZoneControlMode controlMode, - IlluminationZoneType zoneType, - byte[] data) - { - if (!(data?.Length > 0) || data.Length > MaximumNumberOfDataBytes) - { - throw new ArgumentOutOfRangeException(nameof(data)); - } - - this = typeof(IlluminationZoneControlV1).Instantiate(); - _ControlMode = controlMode; - _ZoneType = zoneType; - Array.Copy(data, 0, _Data, 0, data.Length); - } - - /// - /// Gets the type of zone and the type of data needed to control this zone - /// - internal IlluminationZoneType ZoneType - { - get => _ZoneType; - } - - /// - /// Gets the zone control mode - /// - internal IlluminationZoneControlMode ControlMode - { - get => _ControlMode; - } - - /// - /// Gets the control data as a RGB data structure. - /// - /// An instance of containing RGB settings. - public IlluminationZoneControlDataRGB AsRGBData() - { - return _Data.ToStructure(); - } - - /// - /// Gets the control data as a fixed color data structure. - /// - /// An instance of containing fixed color settings. - public IlluminationZoneControlDataFixedColor AsFixedColorData() - { - return _Data.ToStructure(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoParametersV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoParametersV1.cs deleted file mode 100644 index adb4b33b..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoParametersV1.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding illumination zones - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct IlluminationZoneInfoParametersV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - private const int MaximumNumberOfZones = 32; - internal StructureVersion _Version; - internal uint _NumberOfZones; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfZones)] - internal IlluminationZoneInfoV1[] _Zones; - - /// - /// Gets the list of illumination zones. - /// - public IlluminationZoneInfoV1[] Zones - { - get => _Zones.Take((int) _NumberOfZones).ToArray(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoV1.cs deleted file mode 100644 index d405d97a..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/IlluminationZoneInfoV1.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information regarding a illumination zone - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct IlluminationZoneInfoV1 : IInitializable - { - private const int MaximumNumberOfReserved = 64; - private const int MaximumNumberOfDataBytes = 64; - - internal IlluminationZoneType _ZoneType; - internal byte _DeviceIndex; - internal byte _ProviderIndex; - internal IlluminationZoneLocation _ZoneLocation; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfDataBytes)] - internal byte[] _Data; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaximumNumberOfReserved)] - internal byte[] _Reserved; - - /// - /// Gets the index of the illumination device that controls this zone. - /// - public int DeviceIndex - { - get => _DeviceIndex; - } - - /// - /// Gets the provider index used for representing logical to physical zone mapping. - /// - public int ProviderIndex - { - get => _ProviderIndex; - } - - /// - /// Gets the location of the zone on the board. - /// - public IlluminationZoneLocation ZoneLocation - { - get => _ZoneLocation; - } - - /// - /// Gets the zone type. - /// - internal IlluminationZoneType ZoneType - { - get => _ZoneType; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/LogicalGPUHandle.cs b/app/NvAPIWrapper/Native/GPU/Structures/LogicalGPUHandle.cs deleted file mode 100644 index dd7a5c66..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/LogicalGPUHandle.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// LogicalGPUHandle is a reference to one or more physical GPUs acting as a single logical device. A single GPU will - /// have a single logical GPU handle and a single physical GPU handle. Two GPUs acting in an SLI configuration will - /// have a single logical GPU handle and two physical GPU handles. - /// - [StructLayout(LayoutKind.Sequential)] - public struct LogicalGPUHandle : IHandle, IEquatable - { - /// - /// Maximum number of logical GPUs - /// - public const int MaxLogicalGPUs = 64; - - internal readonly IntPtr _MemoryAddress; - - /// - public bool Equals(LogicalGPUHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is LogicalGPUHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - /// - public override string ToString() - { - return $"LogicalGPUHandle #{MemoryAddress.ToInt64()}"; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(LogicalGPUHandle left, LogicalGPUHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(LogicalGPUHandle left, LogicalGPUHandle right) - { - return !left.Equals(right); - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20BaseVoltageEntryV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20BaseVoltageEntryV1.cs deleted file mode 100644 index b84c2139..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20BaseVoltageEntryV1.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStates20BaseVoltageEntryV1 : IPerformanceStates20VoltageEntry - { - internal PerformanceVoltageDomain _DomainId; - internal uint _Flags; - internal uint _Value; - internal PerformanceStates20ParameterDelta _ValueDelta; - - /// - /// Creates a new instance of . - /// - /// The voltage domain. - /// The value in micro volt. - /// The base value delta. - public PerformanceStates20BaseVoltageEntryV1( - PerformanceVoltageDomain domain, - uint value, - PerformanceStates20ParameterDelta valueDelta) : this() - { - _DomainId = domain; - _Value = value; - _ValueDelta = valueDelta; - } - - /// - /// Creates a new instance of . - /// - /// The voltage domain. - /// The base value delta. - public PerformanceStates20BaseVoltageEntryV1( - PerformanceVoltageDomain domain, - PerformanceStates20ParameterDelta valueDelta) : this() - { - _DomainId = domain; - _ValueDelta = valueDelta; - } - - /// - public PerformanceVoltageDomain DomainId - { - get => _DomainId; - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - - /// - public uint ValueInMicroVolt - { - get => _Value; - } - - /// - public PerformanceStates20ParameterDelta ValueDeltaInMicroVolt - { - get => _ValueDelta; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ClockEntryV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ClockEntryV1.cs deleted file mode 100644 index 50b8b489..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ClockEntryV1.cs +++ /dev/null @@ -1,238 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStates20ClockEntryV1 : IPerformanceStates20ClockEntry - { - internal PublicClockDomain _DomainId; - internal PerformanceStates20ClockType _ClockType; - internal uint _Flags; - internal PerformanceStates20ParameterDelta _FrequencyDeltaInkHz; - internal PerformanceStates20ClockDependentInfo _ClockDependentInfo; - - /// - /// Creates a new instance of - /// - /// The public clock domain. - /// The base value delta. - public PerformanceStates20ClockEntryV1( - PublicClockDomain domain, - PerformanceStates20ParameterDelta valueDelta) : this() - { - _DomainId = domain; - _FrequencyDeltaInkHz = valueDelta; - } - - /// - /// Creates a new instance of - /// - /// The public clock domain. - /// The type of the clock frequency. - /// The base value delta. - public PerformanceStates20ClockEntryV1( - PublicClockDomain domain, - PerformanceStates20ClockType clockType, - PerformanceStates20ParameterDelta valueDelta) : this(domain, valueDelta) - { - _ClockType = clockType; - } - - /// - /// Creates a new instance of - /// - /// The public clock domain. - /// The base value delta. - /// The clock frequency value. - // ReSharper disable once TooManyDependencies - public PerformanceStates20ClockEntryV1( - PublicClockDomain domain, - PerformanceStates20ParameterDelta valueDelta, - PerformanceStates20ClockDependentSingleFrequency singleFrequency) : - this(domain, PerformanceStates20ClockType.Single, valueDelta) - { - _ClockDependentInfo = new PerformanceStates20ClockDependentInfo(singleFrequency); - } - - /// - /// Creates a new instance of - /// - /// The public clock domain. - /// The base value delta. - /// The clock frequency range value. - // ReSharper disable once TooManyDependencies - public PerformanceStates20ClockEntryV1( - PublicClockDomain domain, - PerformanceStates20ParameterDelta valueDelta, - PerformanceStates20ClockDependentFrequencyRange frequencyRange) : - this(domain, PerformanceStates20ClockType.Range, valueDelta) - { - _ClockDependentInfo = new PerformanceStates20ClockDependentInfo(frequencyRange); - } - - /// - public PublicClockDomain DomainId - { - get => _DomainId; - } - - /// - public PerformanceStates20ClockType ClockType - { - get => _ClockType; - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - - /// - public PerformanceStates20ParameterDelta FrequencyDeltaInkHz - { - get => _FrequencyDeltaInkHz; - set => _FrequencyDeltaInkHz = value; - } - - /// - IPerformanceStates20ClockDependentSingleFrequency IPerformanceStates20ClockEntry.SingleFrequency - { - get => _ClockDependentInfo._Single; - } - - /// - IPerformanceStates20ClockDependentFrequencyRange IPerformanceStates20ClockEntry.FrequencyRange - { - get => _ClockDependentInfo._Range; - } - - /// - /// Gets the range of clock frequency and related voltage information if present - /// - public PerformanceStates20ClockDependentSingleFrequency SingleFrequency - { - get => _ClockDependentInfo._Single; - } - - /// - /// Gets the fixed frequency of the clock - /// - public PerformanceStates20ClockDependentFrequencyRange FrequencyRange - { - get => _ClockDependentInfo._Range; - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStates20ClockDependentSingleFrequency : - IPerformanceStates20ClockDependentSingleFrequency - { - internal uint _FrequencyInkHz; - - /// - public uint FrequencyInkHz - { - get => _FrequencyInkHz; - } - - /// - /// Creates a new instance of . - /// - /// The fixed frequency in kHz. - public PerformanceStates20ClockDependentSingleFrequency(uint frequencyInkHz) - { - _FrequencyInkHz = frequencyInkHz; - } - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStates20ClockDependentFrequencyRange : - IPerformanceStates20ClockDependentFrequencyRange - { - internal uint _MinimumFrequency; - internal uint _MaximumFrequency; - internal PerformanceVoltageDomain _VoltageDomainId; - internal uint _MinimumVoltage; - internal uint _MaximumVoltage; - - /// - /// Creates a new instance of . - /// - /// The minimum frequency in kHz. - /// The maximum frequency in kHz. - /// The corresponding voltage domain identification number. - /// The minimum voltage in uV. - /// The maximum voltage in uV. - // ReSharper disable once TooManyDependencies - public PerformanceStates20ClockDependentFrequencyRange( - uint minimumFrequency, - uint maximumFrequency, - PerformanceVoltageDomain voltageDomainId, - uint minimumVoltage, - uint maximumVoltage) : this() - { - _MinimumFrequency = minimumFrequency; - _MaximumFrequency = maximumFrequency; - _VoltageDomainId = voltageDomainId; - _MinimumVoltage = minimumVoltage; - _MaximumVoltage = maximumVoltage; - } - - /// - public uint MinimumFrequencyInkHz - { - get => _MinimumFrequency; - } - - /// - public uint MaximumFrequencyInkHz - { - get => _MaximumFrequency; - } - - /// - public PerformanceVoltageDomain VoltageDomainId - { - get => _VoltageDomainId; - } - - /// - public uint MinimumVoltageInMicroVolt - { - get => _MinimumVoltage; - } - - /// - public uint MaximumVoltageInMicroVolt - { - get => _MaximumVoltage; - } - } - - [StructLayout(LayoutKind.Explicit, Pack = 8)] - internal struct PerformanceStates20ClockDependentInfo - { - [FieldOffset(0)] internal PerformanceStates20ClockDependentSingleFrequency _Single; - [FieldOffset(0)] internal PerformanceStates20ClockDependentFrequencyRange _Range; - - public PerformanceStates20ClockDependentInfo( - PerformanceStates20ClockDependentSingleFrequency singleFrequency - ) : this() - { - _Single = singleFrequency; - } - - public PerformanceStates20ClockDependentInfo( - PerformanceStates20ClockDependentFrequencyRange frequencyRange - ) : this() - { - _Range = frequencyRange; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV1.cs deleted file mode 100644 index e5b17b87..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV1.cs +++ /dev/null @@ -1,213 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PerformanceStates20InfoV1 : IInitializable, IPerformanceStates20Info - { - internal const int MaxPerformanceStates = 16; - internal const int MaxPerformanceStatesClocks = 8; - internal const int MaxPerformanceStatesBaseVoltages = 4; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - internal uint _NumberOfBaseVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceState20[] _PerformanceStates; - - /// - /// Creates a new instance of - /// - /// The list of performance states and their settings. - /// Number of clock frequencies per each performance state. - /// Number of base voltage per each performance state. - public PerformanceStates20InfoV1( - PerformanceState20[] performanceStates, - uint clocksCount, - uint baseVoltagesCount) - { - if (performanceStates?.Length > MaxPerformanceStatesClocks) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStates} performance states are configurable.", - nameof(performanceStates) - ); - } - - if (performanceStates == null) - { - throw new ArgumentNullException(nameof(performanceStates)); - } - - this = typeof(PerformanceStates20InfoV1).Instantiate(); - _NumberOfClocks = clocksCount; - _NumberOfBaseVoltages = baseVoltagesCount; - _NumberOfPerformanceStates = (uint) performanceStates.Length; - Array.Copy(performanceStates, 0, _PerformanceStates, 0, performanceStates.Length); - } - - /// - public IPerformanceStates20VoltageEntry[] GeneralVoltages - { - get => new IPerformanceStates20VoltageEntry[0]; - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - - /// - /// Gets an array of valid power states for the GPU - /// - public PerformanceState20[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState20[] IPerformanceStates20Info.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - /// Gets a dictionary for valid power states and their clock frequencies - /// - public IDictionary Clocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - IDictionary IPerformanceStates20Info.Clocks - { - get - { - return Clocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - /// Gets a dictionary for valid power states and their voltage settings - /// - public IReadOnlyDictionary Voltages - { - get - { - var baseVoltages = (int) _NumberOfBaseVoltages; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._BaseVoltages.Take(baseVoltages).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStates20Info.Voltages - { - get - { - return Voltages.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceState20 : IInitializable, IPerformanceState20 - { - internal PerformanceStateId _Id; - internal uint _Flags; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStatesClocks)] - internal PerformanceStates20ClockEntryV1[] _Clocks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStatesBaseVoltages)] - internal PerformanceStates20BaseVoltageEntryV1[] _BaseVoltages; - - /// - /// Creates a new instance of . - /// - /// The performance identification number. - /// The list of clock entries. - /// The list of base voltages. - public PerformanceState20( - PerformanceStateId stateId, - PerformanceStates20ClockEntryV1[] clocks, - PerformanceStates20BaseVoltageEntryV1[] baseVoltages) - { - if (clocks?.Length > MaxPerformanceStatesClocks) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStatesClocks} clocks are configurable.", - nameof(clocks) - ); - } - - if (clocks == null) - { - throw new ArgumentNullException(nameof(clocks)); - } - - if (baseVoltages?.Length > MaxPerformanceStatesBaseVoltages) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStatesBaseVoltages} base voltages are configurable.", - nameof(baseVoltages) - ); - } - - if (baseVoltages == null) - { - throw new ArgumentNullException(nameof(baseVoltages)); - } - - this = typeof(PerformanceState20).Instantiate(); - _Id = stateId; - Array.Copy(clocks, 0, _Clocks, 0, clocks.Length); - Array.Copy(baseVoltages, 0, _BaseVoltages, 0, baseVoltages.Length); - } - - /// - public PerformanceStateId StateId - { - get => _Id; - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV2.cs deleted file mode 100644 index ebf9805c..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV2.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PerformanceStates20InfoV2 : IInitializable, IPerformanceStates20Info - { - internal const int MaxPerformanceStates = PerformanceStates20InfoV1.MaxPerformanceStates; - - internal const int MaxPerformanceStatesBaseVoltages = - PerformanceStates20InfoV1.MaxPerformanceStatesBaseVoltages; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - internal uint _NumberOfBaseVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceStates20InfoV1.PerformanceState20[] _PerformanceStates; - - internal PerformanceStates20OverVoltingSetting _OverVoltingSettings; - - /// - /// Creates a new instance of - /// - /// The list of performance states and their settings. - /// Number of clock frequencies per each performance state. - /// Number of base voltage per each performance state. - public PerformanceStates20InfoV2( - PerformanceStates20InfoV1.PerformanceState20[] performanceStates, - uint clocksCount, - uint baseVoltagesCount) - { - if (performanceStates?.Length > PerformanceStates20InfoV1.MaxPerformanceStatesClocks) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStates} performance states are configurable.", - nameof(performanceStates) - ); - } - - if (performanceStates == null) - { - throw new ArgumentNullException(nameof(performanceStates)); - } - - this = typeof(PerformanceStates20InfoV2).Instantiate(); - _NumberOfClocks = clocksCount; - _NumberOfBaseVoltages = baseVoltagesCount; - _NumberOfPerformanceStates = (uint) performanceStates.Length; - Array.Copy(performanceStates, 0, _PerformanceStates, 0, performanceStates.Length); - } - - /// - /// Creates a new instance of - /// - /// The list of performance states and their settings. - /// Number of clock frequencies per each performance state. - /// Number of base voltage per each performance state. - /// The list of general voltages and their settings. - // ReSharper disable once TooManyDependencies - public PerformanceStates20InfoV2( - PerformanceStates20InfoV1.PerformanceState20[] performanceStates, - uint clocksCount, - uint baseVoltagesCount, - PerformanceStates20BaseVoltageEntryV1[] generalVoltages) : - this(performanceStates, clocksCount, baseVoltagesCount) - { - _OverVoltingSettings = new PerformanceStates20OverVoltingSetting(generalVoltages); - } - - /// - /// Gets the list of general over-volting settings - /// - public PerformanceStates20BaseVoltageEntryV1[] GeneralVoltages - { - get => _OverVoltingSettings.Voltages.ToArray(); - } - - /// - IPerformanceStates20VoltageEntry[] IPerformanceStates20Info.GeneralVoltages - { - get => GeneralVoltages.Cast().ToArray(); - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - - /// - /// Gets an array of valid power states for the GPU - /// - public PerformanceStates20InfoV1.PerformanceState20[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState20[] IPerformanceStates20Info.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - /// Gets a dictionary for valid power states and their clock frequencies - /// - public IDictionary Clocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - /// Gets a dictionary for valid power states and their voltage settings - /// - public IReadOnlyDictionary Voltages - { - get - { - var baseVoltages = (int) _NumberOfBaseVoltages; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._BaseVoltages.Take(baseVoltages) - .ToArray() - ); - } - } - - /// - IDictionary IPerformanceStates20Info.Clocks - { - get - { - return Clocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStates20Info.Voltages - { - get - { - return Voltages.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - internal struct PerformanceStates20OverVoltingSetting : IInitializable - { - internal uint _NumberOfVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStatesBaseVoltages)] - internal PerformanceStates20BaseVoltageEntryV1[] _Voltages; - - public PerformanceStates20OverVoltingSetting(PerformanceStates20BaseVoltageEntryV1[] voltages) - { - if (voltages?.Length > PerformanceStates20InfoV1.MaxPerformanceStatesBaseVoltages) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStatesBaseVoltages} voltages are configurable.", - nameof(voltages) - ); - } - - if (voltages == null) - { - throw new ArgumentNullException(nameof(voltages)); - } - - this = typeof(PerformanceStates20OverVoltingSetting) - .Instantiate(); - _NumberOfVoltages = (uint) voltages.Length; - Array.Copy(voltages, 0, _Voltages, 0, voltages.Length); - } - - public PerformanceStates20BaseVoltageEntryV1[] Voltages - { - get => _Voltages.Take((int) _NumberOfVoltages).ToArray(); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV3.cs deleted file mode 100644 index 85d08937..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20InfoV3.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct PerformanceStates20InfoV3 : IInitializable, IPerformanceStates20Info - { - internal const int MaxPerformanceStates = PerformanceStates20InfoV2.MaxPerformanceStates; - - internal const int MaxPerformanceStates20BaseVoltages = - PerformanceStates20InfoV2.MaxPerformanceStatesBaseVoltages; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - internal uint _NumberOfBaseVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceStates20InfoV1.PerformanceState20[] _PerformanceStates; - - internal PerformanceStates20InfoV2.PerformanceStates20OverVoltingSetting _OverVoltingSettings; - - /// - /// Creates a new instance of - /// - /// The list of performance states and their settings. - /// Number of clock frequencies per each performance state. - /// Number of base voltage per each performance state. - public PerformanceStates20InfoV3( - PerformanceStates20InfoV1.PerformanceState20[] performanceStates, - uint clocksCount, - uint baseVoltagesCount) - { - if (performanceStates?.Length > PerformanceStates20InfoV1.MaxPerformanceStatesClocks) - { - throw new ArgumentException( - $"Maximum of {MaxPerformanceStates} performance states are configurable.", - nameof(performanceStates) - ); - } - - if (performanceStates == null) - { - throw new ArgumentNullException(nameof(performanceStates)); - } - - this = typeof(PerformanceStates20InfoV3).Instantiate(); - _NumberOfClocks = clocksCount; - _NumberOfBaseVoltages = baseVoltagesCount; - _NumberOfPerformanceStates = (uint) performanceStates.Length; - Array.Copy(performanceStates, 0, _PerformanceStates, 0, performanceStates.Length); - } - - /// - /// Creates a new instance of - /// - /// The list of performance states and their settings. - /// Number of clock frequencies per each performance state. - /// Number of base voltage per each performance state. - /// The list of general voltages and their settings. - // ReSharper disable once TooManyDependencies - public PerformanceStates20InfoV3( - PerformanceStates20InfoV1.PerformanceState20[] performanceStates, - uint clocksCount, - uint baseVoltagesCount, - PerformanceStates20BaseVoltageEntryV1[] generalVoltages) : - this(performanceStates, clocksCount, baseVoltagesCount) - { - _OverVoltingSettings = new PerformanceStates20InfoV2.PerformanceStates20OverVoltingSetting(generalVoltages); - } - - /// - /// Gets the list of general over-volting settings - /// - public PerformanceStates20BaseVoltageEntryV1[] GeneralVoltages - { - get => _OverVoltingSettings.Voltages.ToArray(); - } - - /// - IPerformanceStates20VoltageEntry[] IPerformanceStates20Info.GeneralVoltages - { - get => GeneralVoltages.Cast().ToArray(); - } - - /// - public bool IsEditable - { - get => _Flags.GetBit(0); - } - - /// - /// Gets an array of valid power states for the GPU - /// - public PerformanceStates20InfoV1.PerformanceState20[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState20[] IPerformanceStates20Info.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - /// Gets a dictionary for valid power states and their clock frequencies - /// - public IDictionary Clocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - /// Gets a dictionary for valid power states and their voltage settings - /// - public IReadOnlyDictionary Voltages - { - get - { - var baseVoltages = (int) _NumberOfBaseVoltages; - - return PerformanceStates.ToDictionary( - state20 => state20.StateId, - state20 => state20._BaseVoltages.Take(baseVoltages) - .ToArray() - ); - } - } - - /// - IDictionary IPerformanceStates20Info.Clocks - { - get - { - return Clocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStates20Info.Voltages - { - get - { - return Voltages.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ParameterDelta.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ParameterDelta.cs deleted file mode 100644 index d4a5ccf3..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStates20ParameterDelta.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Hold information regarding delta values and delta ranges for voltages or clock frequencies in their respective unit - /// (uV or kHz) - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStates20ParameterDelta - { - internal int _DeltaValue; - internal PerformanceState20ParameterDeltaValueRange _DeltaRange; - - /// - /// Creates a new instance of - /// - /// The delta value. - /// The delta range minimum value. - /// The delta range maximum value. - public PerformanceStates20ParameterDelta(int deltaValue, int deltaMinimum, int deltaMaximum) - { - _DeltaValue = deltaValue; - _DeltaRange = new PerformanceState20ParameterDeltaValueRange(deltaMinimum, deltaMaximum); - } - - - /// - /// Creates a new instance of - /// - /// The delta value. - public PerformanceStates20ParameterDelta(int deltaValue) - { - _DeltaValue = deltaValue; - _DeltaRange = new PerformanceState20ParameterDeltaValueRange(); - } - - /// - /// Gets the delta value in the respective unit (uV or kHz) - /// - public int DeltaValue - { - get => _DeltaValue; - set => _DeltaValue = value; - } - - /// - /// Gets the range of the valid delta values in the respective unit (uV or kHz) - /// - public PerformanceState20ParameterDeltaValueRange DeltaRange - { - get => _DeltaRange; - } - - /// - /// Holds information regarding a range of values - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceState20ParameterDeltaValueRange - { - internal int _Minimum; - internal int _Maximum; - - /// - /// Creates a new instance of . - /// - /// The minimum value of delta range. - /// The maximum value of delta range. - public PerformanceState20ParameterDeltaValueRange(int minimum, int maximum) - { - _Minimum = minimum; - _Maximum = maximum; - } - - /// - /// Gets the minimum value - /// - public int Minimum - { - get => _Minimum; - } - - /// - /// Gets the maximum value - /// - public int Maximum - { - get => _Maximum; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV1.cs deleted file mode 100644 index 90966c7d..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV1.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PerformanceStatesInfoV1 : IInitializable, IPerformanceStatesInfo - { - internal const int MaxPerformanceStates = 16; - internal const int MaxPerformanceStateClocks = 32; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceState[] _PerformanceStates; - - /// - public bool IsPerformanceMonitorEnable - { - get => _Flags.GetBit(0); - } - - /// - public bool IsCapableOfDynamicPerformance - { - get => _Flags.GetBit(1); - } - - /// - public bool IsDynamicPerformanceEnable - { - get => _Flags.GetBit(2); - } - - /// - /// Gets an array of valid and available performance states information - /// - public PerformanceState[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState[] IPerformanceStatesInfo.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - public IReadOnlyDictionary PerformanceStatesVoltages - { - get => new ReadOnlyDictionary( - new Dictionary() - ); - } - - /// - /// Gets a dictionary of valid and available performance states and their clock information as an array - /// - public IReadOnlyDictionary - PerformanceStatesClocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state => state.StateId, - state => state._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStatesInfo. - PerformanceStatesClocks - { - get - { - return PerformanceStatesClocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceState : IInitializable, IPerformanceState - { - internal PerformanceStateId _Id; - internal uint _Flags; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStateClocks)] - internal PerformanceStatesClock[] _Clocks; - - /// - public PerformanceStateId StateId - { - get => _Id; - } - - /// - public bool IsPCIELimited - { - get => _Flags.GetBit(0); - } - - /// - public bool IsOverclocked - { - get => _Flags.GetBit(1); - } - - /// - public bool IsOverclockable - { - get => _Flags.GetBit(2); - } - - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStatesClock : IInitializable, IPerformanceStatesClock - { - internal PublicClockDomain _Id; - internal uint _Flags; - internal uint _Frequency; - - /// - public PublicClockDomain DomainId - { - get => _Id; - } - - /// - public uint Frequency - { - get => _Frequency; - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV2.cs deleted file mode 100644 index 6dfb3f6f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV2.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PerformanceStatesInfoV2 : IInitializable, IPerformanceStatesInfo - { - internal const int MaxPerformanceStates = PerformanceStatesInfoV1.MaxPerformanceStates; - internal const int MaxPerformanceStateClocks = PerformanceStatesInfoV1.MaxPerformanceStateClocks; - internal const int MaxPerformanceStateVoltages = 16; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - internal uint _NumberOfVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceState[] _PerformanceStates; - - /// - public bool IsPerformanceMonitorEnable - { - get => _Flags.GetBit(0); - } - - /// - public bool IsCapableOfDynamicPerformance - { - get => _Flags.GetBit(1); - } - - /// - public bool IsDynamicPerformanceEnable - { - get => _Flags.GetBit(2); - } - - /// - /// Gets an array of valid and available performance states information - /// - public PerformanceState[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState[] IPerformanceStatesInfo.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - /// Gets a dictionary of valid and available performance states and their voltage information as an array - /// - public IReadOnlyDictionary - PerformanceStatesVoltages - { - get - { - var voltages = (int) _NumberOfVoltages; - - return PerformanceStates.ToDictionary( - state => state.StateId, - state => state._Voltages.Take(voltages).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStatesInfo. - PerformanceStatesVoltages - { - get - { - return PerformanceStatesVoltages.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - /// Gets a dictionary of valid and available performance states and their clock information as an array - /// - public IReadOnlyDictionary - PerformanceStatesClocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state => state.StateId, - state => state._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStatesInfo. - PerformanceStatesClocks - { - get - { - return PerformanceStatesClocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceState : IInitializable, IPerformanceState - { - internal PerformanceStateId _Id; - internal uint _Flags; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStateClocks)] - internal PerformanceStatesClock[] _Clocks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStateVoltages)] - internal PerformanceStatesVoltage[] _Voltages; - - /// - public PerformanceStateId StateId - { - get => _Id; - } - - /// - public bool IsPCIELimited - { - get => _Flags.GetBit(0); - } - - /// - public bool IsOverclocked - { - get => _Flags.GetBit(1); - } - - /// - public bool IsOverclockable - { - get => _Flags.GetBit(2); - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStatesVoltage : IInitializable, IPerformanceStatesVoltage - { - internal PerformanceVoltageDomain _Id; - internal uint _Flags; - internal uint _Value; - - /// - public PerformanceVoltageDomain DomainId - { - get => _Id; - } - - /// - public uint Value - { - get => _Value; - } - } - - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PerformanceStatesClock : IInitializable, IPerformanceStatesClock - { - internal PublicClockDomain _Id; - internal uint _Flags; - internal uint _Frequency; - - /// - /// Gets a boolean value indicating if this clock domain is overclockable - /// - public bool IsOverclockable - { - get => _Flags.GetBit(0); - } - - /// - public PublicClockDomain DomainId - { - get => _Id; - } - - /// - public uint Frequency - { - get => _Frequency; - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV3.cs b/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV3.cs deleted file mode 100644 index 6c853887..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PerformanceStatesInfoV3.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct PerformanceStatesInfoV3 : IInitializable, IPerformanceStatesInfo - { - internal const int MaxPerformanceStates = PerformanceStatesInfoV2.MaxPerformanceStates; - internal const int MaxPerformanceStateClocks = PerformanceStatesInfoV2.MaxPerformanceStateClocks; - internal const int MaxPerformanceStateVoltages = PerformanceStatesInfoV2.MaxPerformanceStateVoltages; - - internal StructureVersion _Version; - internal uint _Flags; - internal uint _NumberOfPerformanceStates; - internal uint _NumberOfClocks; - internal uint _NumberOfVoltages; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxPerformanceStates)] - internal PerformanceStatesInfoV2.PerformanceState[] _PerformanceStates; - - /// - public bool IsPerformanceMonitorEnable - { - get => _Flags.GetBit(0); - } - - /// - public bool IsCapableOfDynamicPerformance - { - get => _Flags.GetBit(1); - } - - /// - public bool IsDynamicPerformanceEnable - { - get => _Flags.GetBit(2); - } - - /// - /// Gets an array of valid and available performance states information - /// - public PerformanceStatesInfoV2.PerformanceState[] PerformanceStates - { - get => _PerformanceStates.Take((int) _NumberOfPerformanceStates).ToArray(); - } - - /// - IPerformanceState[] IPerformanceStatesInfo.PerformanceStates - { - get => PerformanceStates.Cast().ToArray(); - } - - /// - /// Gets a dictionary of valid and available performance states and their voltage information as an array - /// - public IReadOnlyDictionary - PerformanceStatesVoltages - { - get - { - var voltages = (int) _NumberOfVoltages; - - return PerformanceStates.ToDictionary( - state => state.StateId, - state => state._Voltages.Take(voltages).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStatesInfo. - PerformanceStatesVoltages - { - get - { - return PerformanceStatesVoltages.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - - /// - /// Gets a dictionary of valid and available performance states and their clock information as an array - /// - public IReadOnlyDictionary - PerformanceStatesClocks - { - get - { - var clocks = (int) _NumberOfClocks; - - return PerformanceStates.ToDictionary( - state => state.StateId, - state => state._Clocks.Take(clocks).ToArray() - ); - } - } - - /// - IReadOnlyDictionary IPerformanceStatesInfo. - PerformanceStatesClocks - { - get - { - return PerformanceStatesClocks.ToDictionary( - pair => pair.Key, - pair => pair.Value.Cast().ToArray() - ); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PhysicalGPUHandle.cs b/app/NvAPIWrapper/Native/GPU/Structures/PhysicalGPUHandle.cs deleted file mode 100644 index 6f062639..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PhysicalGPUHandle.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// PhysicalGPUHandle is a reference to a physical GPU. Each GPU in a multi-GPU board will have its own handle. GPUs - /// are assigned a handle even if they are not in use by the OS. - /// - [StructLayout(LayoutKind.Sequential)] - public struct PhysicalGPUHandle : IHandle, IEquatable - { - /// - /// Queryable number of physical GPUs - /// - public const int PhysicalGPUs = 32; - - /// - /// Maximum number of physical GPUs - /// - public const int MaxPhysicalGPUs = 64; - - internal readonly IntPtr _MemoryAddress; - - /// - public bool Equals(PhysicalGPUHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is PhysicalGPUHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - - /// - public override string ToString() - { - return $"PhysicalGPUHandle #{MemoryAddress.ToInt64()}"; - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(PhysicalGPUHandle left, PhysicalGPUHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(PhysicalGPUHandle left, PhysicalGPUHandle right) - { - return !left.Equals(right); - } - - /// - /// Gets default PhysicalGPUHandle with a null pointer - /// - public static PhysicalGPUHandle DefaultHandle - { - get => default(PhysicalGPUHandle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateActiveApplicationV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateActiveApplicationV2.cs deleted file mode 100644 index 3f758f0f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateActiveApplicationV2.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - [StructureVersion(2)] - [StructLayout(LayoutKind.Sequential)] - public struct PrivateActiveApplicationV2 : IInitializable - { - internal const int MaximumNumberOfApplications = 128; - - internal StructureVersion _Version; - internal uint _ProcessId; - internal LongString _ProcessName; - - public int ProcessId - { - get => (int) _ProcessId; - } - - public string ProcessName - { - get => _ProcessName.Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateArchitectInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateArchitectInfoV2.cs deleted file mode 100644 index 0cf5e70e..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateArchitectInfoV2.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding a GPU architecture - /// - [StructLayout(LayoutKind.Sequential)] - [StructureVersion(2)] - public struct PrivateArchitectInfoV2 : IInitializable - { - internal StructureVersion _Version; - internal uint _Unknown1; - internal uint _Unknown2; - internal uint _Revision; - - /// - /// Gets the GPU revision - /// - public uint Revision - { - get => _Revision; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostLockV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostLockV2.cs deleted file mode 100644 index e990defa..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostLockV2.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding the GPU clock boost locks - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PrivateClockBoostLockV2 : IInitializable - { - internal const int MaxNumberOfClocksPerGPU = ClockFrequenciesV1.MaxClocksPerGPU; - - internal StructureVersion _Version; - internal uint _Unknown; - internal uint _ClockBoostLocksCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfClocksPerGPU)] - internal ClockBoostLock[] _ClockBoostLocks; - - /// - /// Gets the list of clock boost locks - /// - public ClockBoostLock[] ClockBoostLocks - { - get => _ClockBoostLocks.Take((int) _ClockBoostLocksCount).ToArray(); - } - - /// - /// Creates a new instance of - /// - /// The list of clock boost locks - public PrivateClockBoostLockV2(ClockBoostLock[] clockBoostLocks) - { - if (clockBoostLocks?.Length > MaxNumberOfClocksPerGPU) - { - throw new ArgumentException($"Maximum of {MaxNumberOfClocksPerGPU} clocks are configurable.", - nameof(clockBoostLocks)); - } - - if (clockBoostLocks == null || clockBoostLocks.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(clockBoostLocks)); - } - - this = typeof(PrivateClockBoostLockV2).Instantiate(); - _ClockBoostLocksCount = (uint) clockBoostLocks.Length; - Array.Copy(clockBoostLocks, 0, _ClockBoostLocks, 0, clockBoostLocks.Length); - } - - /// - /// Contains information regarding a clock boost lock - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ClockBoostLock - { - internal PublicClockDomain _ClockDomain; - internal uint _Unknown1; - internal ClockLockMode _LockMode; - internal uint _Unknown2; - internal uint _VoltageInMicroV; - internal uint _Unknown3; - - /// - /// Gets the public clock domain - /// - public PublicClockDomain ClockDomain - { - get => _ClockDomain; - } - - /// - /// Gets the clock lock mode - /// - public ClockLockMode LockMode - { - get => _LockMode; - } - - /// - /// Gets the locked voltage in uV - /// - public uint VoltageInMicroV - { - get => _VoltageInMicroV; - } - - /// - /// Creates a new instance of . - /// - /// The public clock domain. - /// The clock lock mode. - /// The locked voltage in uV. - public ClockBoostLock(PublicClockDomain clockDomain, ClockLockMode lockMode, uint voltageInMicroV) : this() - { - _ClockDomain = clockDomain; - _LockMode = lockMode; - _VoltageInMicroV = voltageInMicroV; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostMasksV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostMasksV1.cs deleted file mode 100644 index a7b29a4f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostMasksV1.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU clock boost masks - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateClockBoostMasksV1 : IInitializable - { - internal const int MaxMasks = 4; - internal const int MaxUnknown1 = 8; - internal const int MaxClockBoostMasks = 103; - internal const int MaxUnknown2 = 916; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxMasks)] - internal readonly uint[] _Masks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxUnknown1)] - internal readonly uint[] _Unknown1; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxClockBoostMasks)] - internal readonly ClockBoostMask[] _ClocksBoostMasks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxUnknown2)] - internal readonly uint[] _Unknown2; - - /// - /// Gets a list of clock boost masks - /// - public ClockBoostMask[] ClockBoostMasks - { - get => _ClocksBoostMasks; - } - - /// - /// Contains information regarding a clock boost mask - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ClockBoostMask - { - internal readonly uint _Unknown; - internal readonly uint _Unknown2; - internal readonly uint _Unknown3; - internal readonly uint _Unknown4; - internal readonly int _MemoryDelta; - internal readonly int _GPUDelta; - - /// - /// Memory clock frequency delta - /// - public int MemoryDelta - { - get => _MemoryDelta; - } - - /// - /// GPU clock frequency delta - /// - public int GPUDelta - { - get => _GPUDelta; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostRangesV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostRangesV1.cs deleted file mode 100644 index 465b5196..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostRangesV1.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU clock boost ranges - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateClockBoostRangesV1 : IInitializable - { - internal const int MaxNumberOfClocksPerGPU = ClockFrequenciesV1.MaxClocksPerGPU; - internal const int MaxNumberOfUnknown = 8; - - internal StructureVersion _Version; - internal uint _ClockBoostRangesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown)] - internal uint[] _Unknown; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfClocksPerGPU)] - internal ClockBoostRange[] _ClockBoostRanges; - - /// - /// Gets a list of clock boost ranges - /// - public ClockBoostRange[] ClockBoostRanges - { - get => _ClockBoostRanges.Take((int) _ClockBoostRangesCount).ToArray(); - } - - /// - /// Contains information regarding a clock boost range - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ClockBoostRange - { - internal uint _Unknown1; - internal ClockType _ClockType; - internal uint _Unknown2; - internal uint _Unknown3; - internal uint _Unknown4; - internal uint _Unknown5; - internal uint _Unknown6; - internal uint _Unknown7; - internal uint _Unknown8; - internal uint _Unknown9; - internal int _RangeMaximumInkHz; - internal int _RangeMinimumInkHz; - internal int _MaximumTemperature; - internal uint _Unknown10; - internal uint _Unknown11; - internal uint _Unknown12; - internal uint _Unknown13; - internal uint _Unknown14; - - /// - /// Gets the clock type - /// - public ClockType ClockType - { - get => _ClockType; - } - - /// - /// Gets the maximum boost frequency in kHz - /// - public int MaximumInkHz - { - get => _RangeMaximumInkHz; - } - - /// - /// Gets the minimum boost frequency in kHz - /// - public int MinimumInkHz - { - get => _RangeMinimumInkHz; - } - - /// - /// Gets the maximum boost temperature - /// - public int MaximumTemperature - { - get => _MaximumTemperature; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostTableV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostTableV1.cs deleted file mode 100644 index 9925b73c..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateClockBoostTableV1.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU clock boost table - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateClockBoostTableV1 : IInitializable - { - internal const int MaxNumberOfMasks = 4; - internal const int MaxNumberOfUnknown1 = 12; - internal const int MaxNumberOfGPUDeltas = 80; - internal const int MaxNumberOfMemoryFilled = 23; - internal const int MaxNumberOfMemoryDeltas = 23; - internal const int MaxNumberOfUnknown2 = 1529; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfMasks)] - internal uint[] _Masks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown1)] - internal uint[] _Unknown1; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfGPUDeltas)] - internal GPUDelta[] _GPUDeltas; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfMemoryFilled)] - internal uint[] _MemoryFilled; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfMemoryDeltas)] - internal int[] _MemoryDeltas; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown2)] - internal uint[] _Unknown2; - - /// - /// Gets a list of clock delta entries - /// - public GPUDelta[] GPUDeltas - { - get => _GPUDeltas; - } - - /// - /// Creates a new instance of - /// - /// The list of GPU clock frequency delta entries. - // ReSharper disable once TooManyDependencies - public PrivateClockBoostTableV1(GPUDelta[] gpuDeltas) - { - if (gpuDeltas?.Length > MaxNumberOfGPUDeltas) - { - throw new ArgumentException($"Maximum of {MaxNumberOfGPUDeltas} GPU delta values are configurable.", - nameof(gpuDeltas)); - } - - if (gpuDeltas == null) - { - throw new ArgumentNullException(nameof(gpuDeltas)); - } - - this = typeof(PrivateClockBoostTableV1).Instantiate(); - - Array.Copy(gpuDeltas, 0, _GPUDeltas, 0, gpuDeltas.Length); - } - - - /// - /// Contains information regarding a GPU delta entry in the clock boost table - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct GPUDelta - { - internal uint _Unknown1; - internal uint _Unknown2; - internal uint _Unknown3; - internal uint _Unknown4; - internal uint _Unknown5; - internal int _FrequencyDeltaInkHz; - internal uint _Unknown7; - internal uint _Unknown8; - internal uint _Unknown9; - - /// - /// Gets the frequency delta in kHz - /// - public int FrequencyDeltaInkHz - { - get => _FrequencyDeltaInkHz; - } - - /// - /// Creates a new instance of GPUDelta. - /// - /// The clock frequency in kHz. - public GPUDelta(int frequencyDeltaInkHz) : this() - { - _FrequencyDeltaInkHz = frequencyDeltaInkHz; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerLevelsV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerLevelsV1.cs deleted file mode 100644 index b5dc289f..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerLevelsV1.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU cooler levels - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateCoolerLevelsV1 : IInitializable - { - internal const int MaxNumberOfCoolersPerGPU = PrivateCoolerSettingsV1.MaxNumberOfCoolersPerGPU; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfCoolersPerGPU)] - internal CoolerLevel[] _CoolerLevels; - - /// - /// Gets the list of cooler levels. - /// - /// The number of cooler levels to return. - /// An array of instances. - public CoolerLevel[] GetCoolerLevels(int count) - { - return _CoolerLevels.Take(count).ToArray(); - } - - /// - /// Creates a new instance of . - /// - /// The list of cooler levels. - public PrivateCoolerLevelsV1(CoolerLevel[] levels) - { - if (levels?.Length > MaxNumberOfCoolersPerGPU) - { - throw new ArgumentException($"Maximum of {MaxNumberOfCoolersPerGPU} cooler levels are configurable.", - nameof(levels)); - } - - if (levels == null || levels.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(levels)); - } - - this = typeof(PrivateCoolerLevelsV1).Instantiate(); - Array.Copy(levels, 0, _CoolerLevels, 0, levels.Length); - } - - /// - /// Contains information regarding a cooler level - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct CoolerLevel - { - internal uint _CurrentLevel; - internal CoolerPolicy _CurrentPolicy; - - /// - /// Creates a new instance of - /// - /// The cooler policy. - /// The cooler level in percentage. - public CoolerLevel(CoolerPolicy coolerPolicy, uint level) - { - _CurrentPolicy = coolerPolicy; - _CurrentLevel = level; - } - - /// - /// Creates a new instance of - /// - /// The cooler policy. - public CoolerLevel(CoolerPolicy coolerPolicy) : this(coolerPolicy, 0) - { - if (coolerPolicy == CoolerPolicy.Manual) - { - throw new ArgumentException( - "Manual policy is not valid when no level value is provided.", - nameof(coolerPolicy) - ); - } - } - - /// - /// Creates a new instance of - /// - /// The cooler level in percentage. - public CoolerLevel(uint level) : this(CoolerPolicy.Manual, level) - { - } - - /// - /// Gets the cooler level in percentage. - /// - public uint CurrentLevel - { - get => _CurrentLevel; - } - - /// - /// Gets the cooler policy - /// - public CoolerPolicy CoolerPolicy - { - get => _CurrentPolicy; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerPolicyTableV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerPolicyTableV1.cs deleted file mode 100644 index 5468357a..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerPolicyTableV1.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU cooler policy table - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateCoolerPolicyTableV1 : IInitializable - { - internal const int MaxNumberOfPolicyLevels = 24; - - internal StructureVersion _Version; - internal CoolerPolicy _Policy; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfPolicyLevels)] - internal readonly CoolerPolicyTableEntry[] _TableEntries; - - /// - /// Gets an array of policy table entries - /// - /// The number of table entries. - /// An array of instances. - public CoolerPolicyTableEntry[] TableEntries(int count) - { - return _TableEntries.Take(count).ToArray(); - } - - /// - /// Gets the table cooler policy - /// - public CoolerPolicy Policy - { - get => _Policy; - } - - /// - /// Creates a new instance of - /// - /// The table cooler policy. - /// An array of table entries. - public PrivateCoolerPolicyTableV1(CoolerPolicy policy, CoolerPolicyTableEntry[] policyTableEntries) - { - if (policyTableEntries?.Length > MaxNumberOfPolicyLevels) - { - throw new ArgumentException($"Maximum of {MaxNumberOfPolicyLevels} policy levels are configurable.", - nameof(policyTableEntries)); - } - - if (policyTableEntries == null || policyTableEntries.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(policyTableEntries)); - } - - this = typeof(PrivateCoolerPolicyTableV1).Instantiate(); - _Policy = policy; - Array.Copy(policyTableEntries, 0, _TableEntries, 0, policyTableEntries.Length); - } - - /// - /// Contains information regarding a clock boost mask - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct CoolerPolicyTableEntry - { - internal uint _EntryId; - internal uint _CurrentLevel; - internal uint _DefaultLevel; - - /// - /// Gets the entry identification number - /// - public uint EntryId - { - get => _EntryId; - } - - /// - /// Gets the current level in percentage - /// - public uint CurrentLevel - { - get => _CurrentLevel; - } - - /// - /// Gets the default level in percentage - /// - public uint DefaultLevel - { - get => _DefaultLevel; - } - - /// - /// Creates a new instance of . - /// - /// The entry identification number. - /// The current level in percentage. - /// The default level in percentage. - public CoolerPolicyTableEntry(uint entryId, uint currentLevel, uint defaultLevel) - { - _EntryId = entryId; - _CurrentLevel = currentLevel; - _DefaultLevel = defaultLevel; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerSettingsV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerSettingsV1.cs deleted file mode 100644 index 703bef64..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateCoolerSettingsV1.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU cooler settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateCoolerSettingsV1 : IInitializable - { - internal const int MaxNumberOfCoolersPerGPU = 3; - - internal StructureVersion _Version; - internal readonly uint _CoolerSettingsCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfCoolersPerGPU)] - internal readonly CoolerSetting[] _CoolerSettings; - - /// - /// Gets the list of cooler settings - /// - public CoolerSetting[] CoolerSettings - { - get => _CoolerSettings.Take((int) _CoolerSettingsCount).ToArray(); - } - - /// - /// Contains information regarding a cooler settings - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct CoolerSetting - { - internal CoolerType _CoolerType; - internal CoolerController _CoolerController; - internal uint _DefaultMinimumLevel; - internal uint _DefaultMaximumLevel; - internal uint _CurrentMinimumLevel; - internal uint _CurrentMaximumLevel; - internal uint _CurrentLevel; - internal CoolerPolicy _DefaultPolicy; - internal CoolerPolicy _CurrentPolicy; - internal CoolerTarget _Target; - internal CoolerControlMode _ControlMode; - internal uint _IsActive; - - /// - /// Gets the current cooler level in percentage. - /// - public uint CurrentLevel - { - get => _CurrentLevel; - } - - /// - /// Gets the default minimum cooler level in percentage. - /// - public uint DefaultMinimumLevel - { - get => _DefaultMinimumLevel; - } - - /// - /// Gets the default maximum cooler level in percentage. - /// - public uint DefaultMaximumLevel - { - get => _DefaultMaximumLevel; - } - - /// - /// Gets the current minimum cooler level in percentage. - /// - public uint CurrentMinimumLevel - { - get => _CurrentMinimumLevel; - } - - /// - /// Gets the current maximum cooler level in percentage. - /// - public uint CurrentMaximumLevel - { - get => _CurrentMaximumLevel; - } - - /// - /// Gets the cooler type. - /// - public CoolerType CoolerType - { - get => _CoolerType; - } - - /// - /// Gets the cooler controller. - /// - public CoolerController CoolerController - { - get => _CoolerController; - } - - /// - /// Gets the cooler default policy. - /// - public CoolerPolicy DefaultPolicy - { - get => _DefaultPolicy; - } - - /// - /// Gets the cooler current policy. - /// - public CoolerPolicy CurrentPolicy - { - get => _CurrentPolicy; - } - - /// - /// Gets the cooler target. - /// - public CoolerTarget Target - { - get => _Target; - } - - /// - /// Gets the cooler control mode. - /// - public CoolerControlMode ControlMode - { - get => _ControlMode; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersControlV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersControlV1.cs deleted file mode 100644 index f64f4fd6..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersControlV1.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateFanCoolersControlV1 : IInitializable - { - internal const int MaxNumberOfFanCoolerControlEntries = 32; - internal StructureVersion _Version; - internal readonly uint _UnknownUInt; - internal readonly uint _FanCoolersControlCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfFanCoolerControlEntries)] - internal readonly FanCoolersControlEntry[] _FanCoolersControlEntries; - - public FanCoolersControlEntry[] FanCoolersControlEntries - { - get => _FanCoolersControlEntries.Take((int) _FanCoolersControlCount).ToArray(); - } - - public uint UnknownUInt - { - get => _UnknownUInt; - } - - public PrivateFanCoolersControlV1(FanCoolersControlEntry[] entries, uint unknownUInt = 0) - { - if (entries?.Length > MaxNumberOfFanCoolerControlEntries) - { - throw new ArgumentException( - $"Maximum of {MaxNumberOfFanCoolerControlEntries} coolers are configurable.", - nameof(entries)); - } - - if (entries == null || entries.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(entries)); - } - - entries = entries.OrderBy(entry => entry.CoolerId).ToArray(); - - this = typeof(PrivateFanCoolersControlV1).Instantiate(); - _UnknownUInt = unknownUInt; - _FanCoolersControlCount = (uint) entries.Length; - Array.Copy(entries, 0, _FanCoolersControlEntries, 0, entries.Length); - } - - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct FanCoolersControlEntry - { - internal readonly uint _CoolerId; - internal readonly uint _Level; - internal readonly FanCoolersControlMode _ControlMode; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - public FanCoolersControlEntry(uint coolerId, FanCoolersControlMode controlMode, uint level) - { - this = typeof(FanCoolersControlEntry).Instantiate(); - _CoolerId = coolerId; - _ControlMode = controlMode; - _Level = level; - } - - public FanCoolersControlEntry(uint coolerId, FanCoolersControlMode controlMode) : this(coolerId, - controlMode, 0) - { - if (controlMode == FanCoolersControlMode.Manual) - { - throw new ArgumentException( - "Manual control mode is not valid when no level value is provided.", - nameof(controlMode) - ); - } - } - - public uint CoolerId - { - get => _CoolerId; - } - - public uint Level - { - get => _Level; - } - - public FanCoolersControlMode ControlMode - { - get => _ControlMode; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersInfoV1.cs deleted file mode 100644 index cc60cfdf..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersInfoV1.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateFanCoolersInfoV1 : IInitializable - { - internal const int MaxNumberOfFanCoolerInfoEntries = 32; - - internal StructureVersion _Version; - internal readonly uint _UnknownUInt1; - internal readonly uint _FanCoolersInfoCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfFanCoolerInfoEntries)] - internal readonly FanCoolersInfoEntry[] _FanCoolersInfoEntries; - - public FanCoolersInfoEntry[] FanCoolersInfoEntries - { - get => _FanCoolersInfoEntries.Take((int) _FanCoolersInfoCount).ToArray(); - } - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct FanCoolersInfoEntry - { - internal readonly uint _CoolerId; - internal readonly uint _UnknownUInt3; - internal readonly uint _UnknownUInt4; - internal readonly uint _MaximumRPM; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - public uint CoolerId - { - get => _CoolerId; - } - - public uint MaximumRPM - { - get => _MaximumRPM; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersStatusV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersStatusV1.cs deleted file mode 100644 index a73ae995..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateFanCoolersStatusV1.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateFanCoolersStatusV1 : IInitializable - { - internal const int MaxNumberOfFanCoolerStatusEntries = 32; - - internal StructureVersion _Version; - internal readonly uint _FanCoolersStatusCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfFanCoolerStatusEntries)] - internal readonly FanCoolersStatusEntry[] _FanCoolersStatusEntries; - - public FanCoolersStatusEntry[] FanCoolersStatusEntries - { - get => _FanCoolersStatusEntries.Take((int) _FanCoolersStatusCount).ToArray(); - } - - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct FanCoolersStatusEntry - { - internal readonly uint _CoolerId; - internal readonly uint _CurrentRPM; - internal readonly uint _CurrentMinimumLevel; - internal readonly uint _CurrentMaximumLevel; - internal readonly uint _CurrentLevel; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8, ArraySubType = UnmanagedType.U4)] - internal readonly uint[] _Reserved; - - public uint CoolerId - { - get => _CoolerId; - } - - public uint CurrentRPM - { - get => _CurrentRPM; - } - - public uint CurrentMinimumLevel - { - get => _CurrentMinimumLevel; - } - - public uint CurrentMaximumLevel - { - get => _CurrentMaximumLevel; - } - - public uint CurrentLevel - { - get => _CurrentLevel; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePCIeInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePCIeInfoV2.cs deleted file mode 100644 index fc7c775d..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePCIeInfoV2.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU PCI-e connection configurations - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PrivatePCIeInfoV2 : IInitializable - { - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] - internal readonly PCIePerformanceStateInfo[] _PCIePerformanceStateInfos; - - /// - /// Gets the list of performance state PCI-e configurations information - /// - public PCIePerformanceStateInfo[] PCIePerformanceStateInfos - { - get => _PCIePerformanceStateInfos; - } - - /// - /// Contains information regarding a performance state PCI-e connection - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PCIePerformanceStateInfo - { - internal readonly uint _TransferRate; - internal readonly PCIeGeneration _Version; - internal readonly uint _LanesNumber; - internal readonly PCIeGeneration _Generation; - - /// - /// Gets the PCI-e transfer rate in Mega Transfers per Second - /// - public uint TransferRateInMTps - { - get => _TransferRate; - } - - /// - /// Gets the PCI-e generation - /// - public PCIeGeneration Generation - { - get => _Generation; - } - - /// - /// Gets the PCI-e down stream lanes - /// - public uint Lanes - { - get => _LanesNumber; - } - - /// - /// Gets the PCI-e version - /// - public PCIeGeneration Version - { - get => _Version; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceInfoV1.cs deleted file mode 100644 index 74f926a4..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceInfoV1.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU performance limitations - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivatePerformanceInfoV1 : IInitializable - { - internal const int MaxNumberOfUnknown2 = 16; - - internal StructureVersion _Version; - internal uint _Unknown1; - internal PerformanceLimit _SupportedLimits; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown2)] - internal uint[] _Unknown2; - - /// - /// Gets a boolean value indicating if performance limit by power usage is supported. - /// - public bool IsPowerLimitSupported - { - get => _SupportedLimits.HasFlag(PerformanceLimit.PowerLimit); - } - - - /// - /// Gets a boolean value indicating if performance limit by temperature is supported. - /// - public bool IsTemperatureLimitSupported - { - get => _SupportedLimits.HasFlag(PerformanceLimit.TemperatureLimit); - } - - - /// - /// Gets a boolean value indicating if performance limit by voltage usage is supported. - /// - public bool IsVoltageLimitSupported - { - get => _SupportedLimits.HasFlag(PerformanceLimit.VoltageLimit); - } - - - /// - /// Gets a boolean value indicating if performance limit by detecting no load is supported. - /// - public bool IsNoLoadLimitSupported - { - get => _SupportedLimits.HasFlag(PerformanceLimit.NoLoadLimit); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceStatusV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceStatusV1.cs deleted file mode 100644 index 53672b8e..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePerformanceStatusV1.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU performance limitations status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivatePerformanceStatusV1 : IInitializable - { - internal const int MaxNumberOfTimers = 3; - internal const int MaxNumberOfUnknown5 = 326; - - internal StructureVersion _Version; - internal uint _Unknown1; - internal ulong _TimerInNanoSecond; - internal PerformanceLimit _PerformanceLimit; - internal uint _Unknown2; - internal uint _Unknown3; - internal uint _Unknown4; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfTimers)] - internal ulong[] _TimersInNanoSecond; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown5)] - internal uint[] _Unknown5; - - /// - /// Gets the current effective performance limitation - /// - public PerformanceLimit PerformanceLimit - { - get => _PerformanceLimit; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesInfoV1.cs deleted file mode 100644 index 5e183317..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesInfoV1.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU power policies - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivatePowerPoliciesInfoV1 : IInitializable - { - internal const int MaxNumberOfPowerPolicyInfoEntries = 4; - - internal StructureVersion _Version; - internal readonly byte _Valid; - internal readonly byte _PowerPolicyEntriesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfPowerPolicyInfoEntries)] - internal readonly PowerPolicyInfoEntry[] _PowerPolicyInfoEntries; - - /// - /// Gets a list of power policy entries - /// - public PowerPolicyInfoEntry[] PowerPolicyInfoEntries - { - get => _PowerPolicyInfoEntries.Take(_PowerPolicyEntriesCount).ToArray(); - } - - /// - /// Contains information regarding a GPU power policy entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PowerPolicyInfoEntry - { - internal PerformanceStateId _StateId; - internal uint _Unknown1; - internal uint _Unknown2; - internal uint _MinimumPower; - internal uint _Unknown3; - internal uint _Unknown4; - internal uint _DefaultPower; - internal uint _Unknown5; - internal uint _Unknown6; - internal uint _MaximumPower; - internal uint _Unknown7; - - /// - /// Gets the performance state identification number - /// - public PerformanceStateId PerformanceStateId - { - get => _StateId; - } - - /// - /// Gets the minimum power limit in per cent mille - /// - public uint MinimumPowerInPCM - { - get => _MinimumPower; - } - - /// - /// Gets the default power limit in per cent mille - /// - public uint DefaultPowerInPCM - { - get => _DefaultPower; - } - - /// - /// Gets the maximum power limit in per cent mille - /// - public uint MaximumPowerInPCM - { - get => _MaximumPower; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesStatusV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesStatusV1.cs deleted file mode 100644 index c8438e30..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerPoliciesStatusV1.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU power policies status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivatePowerPoliciesStatusV1 : IInitializable - { - internal const int MaxNumberOfPowerPoliciesStatusEntries = 4; - - internal StructureVersion _Version; - internal readonly uint _PowerPoliciesStatusEntriesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfPowerPoliciesStatusEntries, - ArraySubType = UnmanagedType.Struct)] - internal readonly PowerPolicyStatusEntry[] _PowerPoliciesStatusEntries; - - /// - /// Gets a list of power policy status entries - /// - public PowerPolicyStatusEntry[] PowerPolicyStatusEntries - { - get => _PowerPoliciesStatusEntries.Take((int) _PowerPoliciesStatusEntriesCount).ToArray(); - } - - /// - /// Creates a new instance of - /// - /// The list of power policy status entries. - public PrivatePowerPoliciesStatusV1(PowerPolicyStatusEntry[] powerPoliciesStatusEntries) - { - if (powerPoliciesStatusEntries?.Length > MaxNumberOfPowerPoliciesStatusEntries) - { - throw new ArgumentException( - $"Maximum of {MaxNumberOfPowerPoliciesStatusEntries} power policies entries are configurable.", - nameof(powerPoliciesStatusEntries) - ); - } - - if (powerPoliciesStatusEntries == null || powerPoliciesStatusEntries.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(powerPoliciesStatusEntries)); - } - - this = typeof(PrivatePowerPoliciesStatusV1).Instantiate(); - _PowerPoliciesStatusEntriesCount = (uint) powerPoliciesStatusEntries.Length; - Array.Copy( - powerPoliciesStatusEntries, - 0, - _PowerPoliciesStatusEntries, - 0, - powerPoliciesStatusEntries.Length - ); - } - - /// - /// Contains information regarding a power policies status entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PowerPolicyStatusEntry - { - internal PerformanceStateId _PerformanceStateId; - internal uint _Unknown1; - internal uint _PowerTargetInPCM; - internal uint _Unknown2; - - /// - /// Gets the performance state identification number - /// - public PerformanceStateId PerformanceStateId - { - get => _PerformanceStateId; - } - - /// - /// Creates a new instance of PowerPolicyStatusEntry. - /// - /// The power limit target in per cent mille. - public PowerPolicyStatusEntry(uint powerTargetInPCM) : this() - { - _PowerTargetInPCM = powerTargetInPCM; - } - - /// - /// Gets the power limit target in per cent mille - /// - public uint PowerTargetInPCM - { - get => _PowerTargetInPCM; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerTopologiesStatusV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerTopologiesStatusV1.cs deleted file mode 100644 index 1f63a835..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivatePowerTopologiesStatusV1.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU power topology status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivatePowerTopologiesStatusV1 : IInitializable - { - internal const int MaxNumberOfPowerTopologiesStatusEntries = 4; - - internal StructureVersion _Version; - internal readonly uint _PowerTopologiesStatusEntriesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfPowerTopologiesStatusEntries, - ArraySubType = UnmanagedType.Struct)] - internal readonly PowerTopologiesStatusEntry[] _PowerTopologiesStatusEntries; - - /// - /// Gets a list of power topology status entries - /// - public PowerTopologiesStatusEntry[] PowerPolicyStatusEntries - { - get => _PowerTopologiesStatusEntries.Take((int) _PowerTopologiesStatusEntriesCount).ToArray(); - } - - /// - /// Contains information regarding a power topology status entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct PowerTopologiesStatusEntry - { - internal PowerTopologyDomain _Domain; - internal uint _Unknown2; - internal uint _PowerUsageInPCM; - internal uint _Unknown3; - - /// - /// Gets the power topology domain - /// - public PowerTopologyDomain Domain - { - get => _Domain; - } - - /// - /// Gets the power usage in per cent mille - /// - public uint PowerUsageInPCM - { - get => _PowerUsageInPCM; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesInfoV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesInfoV2.cs deleted file mode 100644 index 0796f4aa..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesInfoV2.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU thermal policies - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PrivateThermalPoliciesInfoV2 : IInitializable - { - internal const int MaxNumberOfThermalPoliciesInfoEntries = 4; - - internal StructureVersion _Version; - internal readonly byte _ThermalPoliciesInfoCount; - internal readonly byte _Unknown; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfThermalPoliciesInfoEntries, - ArraySubType = UnmanagedType.Struct)] - internal readonly ThermalPoliciesInfoEntry[] _ThermalPoliciesInfoEntries; - - /// - /// Gets a list of thermal policy entries - /// - public ThermalPoliciesInfoEntry[] ThermalPoliciesInfoEntries - { - get => _ThermalPoliciesInfoEntries.Take(_ThermalPoliciesInfoCount).ToArray(); - } - - /// - /// Contains information regarding a thermal policies entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ThermalPoliciesInfoEntry - { - internal ThermalController _Controller; - internal uint _Unknown1; - internal int _MinimumTemperature; - internal int _DefaultTemperature; - internal int _MaximumTemperature; - internal uint _Unknown2; - - /// - /// Gets the thermal controller - /// - public ThermalController Controller - { - get => _Controller; - } - - /// - /// Gets the minimum temperature limit target - /// - public int MinimumTemperature - { - get => _MinimumTemperature >> 8; - } - - /// - /// Gets the default temperature limit target - /// - public int DefaultTemperature - { - get => _DefaultTemperature >> 8; - } - - /// - /// Gets the maximum temperature limit target - /// - public int MaximumTemperature - { - get => _MaximumTemperature >> 8; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesStatusV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesStatusV2.cs deleted file mode 100644 index 37cb9a6b..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateThermalPoliciesStatusV2.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU thermal policies status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct PrivateThermalPoliciesStatusV2 : IInitializable - { - internal const int MaxNumberOfThermalPoliciesStatusEntries = 4; - - internal StructureVersion _Version; - internal readonly uint _ThermalPoliciesStatusEntriesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfThermalPoliciesStatusEntries)] - internal readonly ThermalPoliciesStatusEntry[] _ThermalPoliciesStatusEntries; - - /// - /// Gets a list of thermal policy status entries - /// - public ThermalPoliciesStatusEntry[] ThermalPoliciesStatusEntries - { - get => _ThermalPoliciesStatusEntries.Take((int) _ThermalPoliciesStatusEntriesCount).ToArray(); - } - - /// - /// Creates a new instance of - /// - /// The list of thermal policy status entries - public PrivateThermalPoliciesStatusV2(ThermalPoliciesStatusEntry[] policiesStatusEntries) - { - if (policiesStatusEntries?.Length > MaxNumberOfThermalPoliciesStatusEntries) - { - throw new ArgumentException( - $"Maximum of {MaxNumberOfThermalPoliciesStatusEntries} thermal policies entries are configurable.", - nameof(policiesStatusEntries) - ); - } - - if (policiesStatusEntries == null || policiesStatusEntries.Length == 0) - { - throw new ArgumentException("Array is null or empty.", nameof(policiesStatusEntries)); - } - - this = typeof(PrivateThermalPoliciesStatusV2).Instantiate(); - _ThermalPoliciesStatusEntriesCount = (uint) policiesStatusEntries.Length; - Array.Copy( - policiesStatusEntries, - 0, - _ThermalPoliciesStatusEntries, - 0, - policiesStatusEntries.Length - ); - } - - /// - /// Contains information regarding a thermal policies status entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct ThermalPoliciesStatusEntry - { - internal ThermalController _Controller; - internal int _TargetTemperature; - internal PerformanceStateId _PerformanceStateId; - - /// - /// Creates a new instance of - /// - /// The thermal controller - /// The target temperature. - public ThermalPoliciesStatusEntry(ThermalController controller, int targetTemperature) : this() - { - _Controller = controller; - _TargetTemperature = targetTemperature * 256; - } - - /// - /// Creates a new instance of - /// - /// The performance state identification number - /// The thermal controller - /// The target temperature. - public ThermalPoliciesStatusEntry( - PerformanceStateId performanceStateId, - ThermalController controller, - int targetTemperature) : this(controller, targetTemperature) - { - _PerformanceStateId = performanceStateId; - } - - /// - /// Gets the thermal controller - /// - public ThermalController Controller - { - get => _Controller; - } - - /// - /// Gets the performance state identification number - /// - public PerformanceStateId PerformanceStateId - { - get => _PerformanceStateId; - } - - /// - /// Gets the target temperature - /// - public int TargetTemperature - { - get => _TargetTemperature >> 8; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateUsagesInfoV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateUsagesInfoV1.cs deleted file mode 100644 index 517feecd..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateUsagesInfoV1.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the GPU usage statistics - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateUsagesInfoV1 : IInitializable, IUtilizationStatus - { - internal const int MaxNumberOfUsageEntries = DynamicPerformanceStatesInfoV1.MaxGpuUtilizations; - - internal StructureVersion _Version; - internal uint _Unknown; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUsageEntries, ArraySubType = UnmanagedType.Struct)] - internal UsagesInfoEntry[] _UsagesInfoEntries; - - /// - public Dictionary Domains - { - get => _UsagesInfoEntries - .Select((value, index) => new {index, value}) - .Where(arg => Enum.IsDefined(typeof(UtilizationDomain), arg.index) && arg.value.IsPresent) - .ToDictionary(arg => (UtilizationDomain) arg.index, arg => arg.value as IUtilizationDomainInfo); - } - - /// - public IUtilizationDomainInfo GPU - { - get => _UsagesInfoEntries[(int) UtilizationDomain.GPU]; - } - - /// - public IUtilizationDomainInfo FrameBuffer - { - get => _UsagesInfoEntries[(int) UtilizationDomain.FrameBuffer]; - } - - /// - public IUtilizationDomainInfo VideoEngine - { - get => _UsagesInfoEntries[(int) UtilizationDomain.VideoEngine]; - } - - /// - public IUtilizationDomainInfo BusInterface - { - get => _UsagesInfoEntries[(int) UtilizationDomain.BusInterface]; - } - - /// - public override string ToString() - { - return $"GPU = {GPU} - " + - $"FrameBuffer = {FrameBuffer} - " + - $"VideoEngine = {VideoEngine} - " + - $"BusInterface = {BusInterface}"; - } - - /// - /// Holds information about the usage statistics for a domain - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct UsagesInfoEntry : IUtilizationDomainInfo - { - internal uint _IsPresent; - internal uint _Percentage; - internal uint _Unknown1; - internal uint _Unknown2; - - /// - public bool IsPresent - { - get => _IsPresent > 0; - } - - /// - public uint Percentage - { - get => _Percentage; - } - - /// - public override string ToString() - { - return IsPresent ? $"{Percentage}%" : "N/A"; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVFPCurveV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateVFPCurveV1.cs deleted file mode 100644 index 2963702b..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVFPCurveV1.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU boost frequency curve - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateVFPCurveV1 : IInitializable - { - internal const int MaxNumberOfMasks = 4; - internal const int MaxNumberOfUnknown1 = 12; - internal const int MaxNumberOfGPUCurveEntries = 80; - internal const int MaxNumberOfMemoryCurveEntries = 23; - internal const int MaxNumberOfUnknown2 = 1064; - - internal StructureVersion _Version; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfMasks)] - internal readonly uint[] _Masks; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown1)] - internal readonly uint[] _Unknown1; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfGPUCurveEntries)] - internal readonly VFPCurveEntry[] _GPUCurveEntries; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfMemoryCurveEntries)] - internal readonly VFPCurveEntry[] _MemoryCurveEntries; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown2)] - internal readonly uint[] _Unknown2; - - - /// - /// Gets the list of GPU curve entries - /// - public VFPCurveEntry[] GPUCurveEntries - { - get => _GPUCurveEntries; - } - - /// - /// Gets the list of memory curve entries - /// - public VFPCurveEntry[] MemoryCurveEntries - { - get => _MemoryCurveEntries; - } - - /// - /// Contains information regarding a boost frequency curve entry - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct VFPCurveEntry - { - internal uint _Unknown1; - internal uint _FrequencyInkHz; - internal uint _VoltageInMicroV; - internal uint _Unknown2; - internal uint _Unknown3; - internal uint _Unknown4; - internal uint _Unknown5; - - /// - /// Gets the frequency in kHz - /// - public uint FrequencyInkHz - { - get => _FrequencyInkHz; - } - - /// - /// Gets the voltage in uV - /// - public uint VoltageInMicroV - { - get => _VoltageInMicroV; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageBoostPercentV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageBoostPercentV1.cs deleted file mode 100644 index 13822ec1..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageBoostPercentV1.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU voltage boost percentage - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateVoltageBoostPercentV1 : IInitializable - { - internal const int MaxNumberOfUnknown = 8; - - internal StructureVersion _Version; - - internal readonly uint _Percent; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown)] - internal readonly uint[] _Unknown; - - /// - /// Gets the voltage boost in percentage - /// - public uint Percent - { - get => _Percent; - } - - /// - /// Creates a new instance of - /// - /// The voltage boost in percentage - public PrivateVoltageBoostPercentV1(uint percent) - { - this = typeof(PrivateVoltageBoostPercentV1).Instantiate(); - _Percent = percent; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageStatusV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageStatusV1.cs deleted file mode 100644 index 583985d8..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/PrivateVoltageStatusV1.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Contains information regarding GPU voltage boost status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct PrivateVoltageStatusV1 : IInitializable - { - internal const int MaxNumberOfUnknown2 = 8; - internal const int MaxNumberOfUnknown3 = 8; - - internal StructureVersion _Version; - - internal readonly uint _Unknown1; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown2)] - internal readonly uint[] _Unknown2; - - internal readonly uint _ValueInuV; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxNumberOfUnknown3)] - internal readonly uint[] _Unknown3; - - /// - /// Gets the value in uV - /// - public uint ValueInMicroVolt - { - get => _ValueInuV; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/QueryIlluminationSupportParameterV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/QueryIlluminationSupportParameterV1.cs deleted file mode 100644 index 49d733d4..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/QueryIlluminationSupportParameterV1.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds necessary information to get an illumination attribute support status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct QueryIlluminationSupportParameterV1 : IInitializable - { - internal StructureVersion _Version; - internal PhysicalGPUHandle _GPUHandle; - internal IlluminationAttribute _Attribute; - internal uint _IsSupported; - - /// - /// Creates a new instance of . - /// - /// The physical gpu handle. - /// The attribute. - public QueryIlluminationSupportParameterV1(PhysicalGPUHandle gpuHandle, IlluminationAttribute attribute) - { - this = typeof(QueryIlluminationSupportParameterV1).Instantiate(); - _GPUHandle = gpuHandle; - _Attribute = attribute; - } - - /// - /// Gets the parameter physical gpu handle - /// - public PhysicalGPUHandle PhysicalGPUHandle - { - get => _GPUHandle; - } - - /// - /// Gets the parameter attribute - /// - public IlluminationAttribute Attribute - { - get => _Attribute; - } - - /// - /// Gets a boolean value indicating if this attribute is supported and controllable via this GPU - /// - public bool IsSupported - { - get => _IsSupported > 0; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/SetIlluminationParameterV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/SetIlluminationParameterV1.cs deleted file mode 100644 index 041bbc8c..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/SetIlluminationParameterV1.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds necessary information to set an illumination attribute value - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct SetIlluminationParameterV1 : IInitializable - { - internal StructureVersion _Version; - internal PhysicalGPUHandle _GPUHandle; - internal IlluminationAttribute _Attribute; - internal uint _ValueInPercentage; - - /// - /// Creates a new instance of . - /// - /// The physical gpu handle. - /// The attribute. - /// The attribute value in percentage. - public SetIlluminationParameterV1( - PhysicalGPUHandle gpuHandle, - IlluminationAttribute attribute, - uint valueInPercentage) - { - this = typeof(SetIlluminationParameterV1).Instantiate(); - _GPUHandle = gpuHandle; - _Attribute = attribute; - _ValueInPercentage = valueInPercentage; - } - - /// - /// Gets the parameter physical gpu handle - /// - public PhysicalGPUHandle PhysicalGPUHandle - { - get => _GPUHandle; - } - - /// - /// Gets the parameter attribute - /// - public IlluminationAttribute Attribute - { - get => _Attribute; - } - - /// - /// Gets the parameter value in percentage - /// - public uint ValueInPercentage - { - get => _ValueInPercentage; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV1.cs b/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV1.cs deleted file mode 100644 index 6364f46d..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV1.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds a list of thermal sensor information settings (temperature values) - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ThermalSettingsV1 : IInitializable, IThermalSettings - { - internal const int MaxThermalSensorsPerGPU = 3; - - internal StructureVersion _Version; - internal readonly uint _Count; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxThermalSensorsPerGPU)] - internal readonly ThermalSensor[] - _Sensors; - - /// - public IThermalSensor[] Sensors - { - get => _Sensors.Take((int) _Count).Cast().ToArray(); - } - - /// - /// Holds information about a single thermal sensor - /// - [StructLayout(LayoutKind.Sequential)] - public struct ThermalSensor : IThermalSensor - { - internal readonly ThermalController _Controller; - internal readonly uint _DefaultMinTemp; - internal readonly uint _DefaultMaxTemp; - internal readonly uint _CurrentTemp; - internal readonly ThermalSettingsTarget _Target; - - /// - public ThermalController Controller - { - get => _Controller; - } - - /// - public int DefaultMinimumTemperature - { - get => (int) _DefaultMinTemp; - } - - /// - public int DefaultMaximumTemperature - { - get => (int) _DefaultMaxTemp; - } - - /// - public int CurrentTemperature - { - get => (int) _CurrentTemp; - } - - /// - public ThermalSettingsTarget Target - { - get => _Target; - } - - /// - public override string ToString() - { - return - $"[{Target} @ {Controller}] Current: {CurrentTemperature}°C - Default Range: [({DefaultMinimumTemperature}°C) , ({DefaultMaximumTemperature}°C)]"; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV2.cs b/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV2.cs deleted file mode 100644 index 73227dc2..00000000 --- a/app/NvAPIWrapper/Native/GPU/Structures/ThermalSettingsV2.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds a list of thermal sensor information settings (temperature values) - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct ThermalSettingsV2 : IInitializable, IThermalSettings - { - internal StructureVersion _Version; - internal readonly uint _Count; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = ThermalSettingsV1.MaxThermalSensorsPerGPU)] - internal readonly - ThermalSensor[] _Sensors; - - /// - public IThermalSensor[] Sensors - { - get => _Sensors.Take((int) _Count).Cast().ToArray(); - } - - /// - /// Holds information about a single thermal sensor - /// - [StructLayout(LayoutKind.Sequential)] - public struct ThermalSensor : IThermalSensor - { - internal readonly ThermalController _Controller; - internal readonly int _DefaultMinTemp; - internal readonly int _DefaultMaxTemp; - internal readonly int _CurrentTemp; - internal readonly ThermalSettingsTarget _Target; - - /// - public ThermalController Controller - { - get => _Controller; - } - - /// - public int DefaultMinimumTemperature - { - get => _DefaultMinTemp; - } - - /// - public int DefaultMaximumTemperature - { - get => _DefaultMaxTemp; - } - - /// - public int CurrentTemperature - { - get => _CurrentTemp; - } - - /// - public ThermalSettingsTarget Target - { - get => _Target; - } - - /// - public override string ToString() - { - return - $"[{Target} @ {Controller}] Current: {CurrentTemperature}°C - Default Range: [({DefaultMinimumTemperature}°C) , ({DefaultMaximumTemperature}°C)]"; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/SystemType.cs b/app/NvAPIWrapper/Native/GPU/SystemType.cs deleted file mode 100644 index 935be412..00000000 --- a/app/NvAPIWrapper/Native/GPU/SystemType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// GPU systems - /// - public enum SystemType - { - /// - /// Unknown type - /// - Unknown = 0, - - /// - /// Laptop GPU - /// - Laptop = 1, - - /// - /// Desktop GPU - /// - Desktop = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ThermalController.cs b/app/NvAPIWrapper/Native/GPU/ThermalController.cs deleted file mode 100644 index e835ad9d..00000000 --- a/app/NvAPIWrapper/Native/GPU/ThermalController.cs +++ /dev/null @@ -1,73 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// List of possible thermal sensor controllers - /// - public enum ThermalController - { - /// - /// No Thermal Controller - /// - None = 0, - - /// - /// GPU acting as thermal controller - /// - GPU, - - /// - /// ADM1032 Thermal Controller - /// - ADM1032, - - /// - /// MAX6649 Thermal Controller - /// - MAX6649, - - /// - /// MAX1617 Thermal Controller - /// - MAX1617, - - /// - /// LM99 Thermal Controller - /// - LM99, - - /// - /// LM89 Thermal Controller - /// - LM89, - - /// - /// LM64 Thermal Controller - /// - LM64, - - /// - /// ADT7473 Thermal Controller - /// - ADT7473, - - /// - /// SBMAX6649 Thermal Controller - /// - SBMAX6649, - - /// - /// VideoBios acting as thermal controller - /// - VideoBiosEvent, - - /// - /// Operating System acting as thermal controller - /// - OperatingSystem, - - /// - /// Unknown Thermal Controller - /// - Unknown = -1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/ThermalSettingsTarget.cs b/app/NvAPIWrapper/Native/GPU/ThermalSettingsTarget.cs deleted file mode 100644 index 9f38417d..00000000 --- a/app/NvAPIWrapper/Native/GPU/ThermalSettingsTarget.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.GPU -{ - /// - /// List of possible thermal targets - /// - [Flags] - public enum ThermalSettingsTarget - { - /// - /// None - /// - None = 0, - - /// - /// GPU core temperature - /// - GPU = 1, - - /// - /// GPU memory temperature - /// - Memory = 2, - - /// - /// GPU power supply temperature - /// - PowerSupply = 4, - - /// - /// GPU board ambient temperature - /// - Board = 8, - - /// - /// Visual Computing Device Board temperature requires NvVisualComputingDeviceHandle - /// - VisualComputingBoard = 9, - - /// - /// Visual Computing Device Inlet temperature requires NvVisualComputingDeviceHandle - /// - VisualComputingInlet = 10, - - /// - /// Visual Computing Device Outlet temperature requires NvVisualComputingDeviceHandle - /// - VisualComputingOutlet = 11, - - /// - /// Used for retrieving all thermal settings - /// - All = 15, - - /// - /// Unknown thermal target - /// - Unknown = -1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPU/UtilizationDomain.cs b/app/NvAPIWrapper/Native/GPU/UtilizationDomain.cs deleted file mode 100644 index d8d4ff6e..00000000 --- a/app/NvAPIWrapper/Native/GPU/UtilizationDomain.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.GPU -{ - /// - /// Valid utilization domain - /// - public enum UtilizationDomain - { - /// - /// GPU utilization domain - /// - GPU, - - /// - /// Frame buffer utilization domain - /// - FrameBuffer, - - /// - /// Video engine utilization domain - /// - VideoEngine, - - /// - /// Bus interface utilization domain - /// - BusInterface - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.Display.cs b/app/NvAPIWrapper/Native/GPUApi.Display.cs deleted file mode 100644 index 0276e788..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.Display.cs +++ /dev/null @@ -1,505 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native.Display.Structures; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// This function is the same as GetAllOutputs() but returns only the set of GPU output identifiers that are actively - /// driving display devices. - /// - /// Physical GPU handle to get information about - /// Active output identifications as a flag - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static OutputId GetActiveOutputs(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var outputMask); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return outputMask; - } - - /// - /// This API returns display IDs for all possible outputs on the GPU. - /// For DPMST connector, it will return display IDs for all the video sinks in the topology. - /// - /// Physical GPU handle to get information about - /// An array of display identifications and their attributes - /// This operation is not supported. - /// See NVIDIAApiException.Status for the reason of the exception. - /// A delegate callback throws an exception. - public static DisplayIdsV2[] GetAllDisplayIds(PhysicalGPUHandle gpuHandle) - { - var gpuGetConnectedDisplayIds = DelegateFactory.GetDelegate(); - - if (!gpuGetConnectedDisplayIds.Accepts().Contains(typeof(DisplayIdsV2))) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - uint count = 0; - var status = gpuGetConnectedDisplayIds(gpuHandle, ValueTypeArray.Null, ref count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (count == 0) - { - return new DisplayIdsV2[0]; - } - - using ( - var displayIds = - ValueTypeArray.FromArray(typeof(DisplayIdsV2).Instantiate().Repeat((int) count))) - { - status = gpuGetConnectedDisplayIds(gpuHandle, displayIds, ref count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayIds.ToArray((int) count); - } - } - - /// - /// Due to space limitation GetConnectedOutputs() can return maximum 32 devices, but this is no longer true for DPMST. - /// GetConnectedDisplayIds() will return all the connected display devices in the form of displayIds for the associated - /// gpuHandle. - /// This function can accept set of flags to request cached, un-cached, sli and lid to get the connected devices. - /// Default value for flags will be cached. - /// - /// Physical GPU handle to get information about - /// ConnectedIdsFlag flags - /// An array of display identifications and their attributes - /// This operation is not supported. - /// Status.InvalidArgument: gpuHandle is invalid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - /// A delegate callback throws an exception. - public static DisplayIdsV2[] GetConnectedDisplayIds(PhysicalGPUHandle gpuHandle, ConnectedIdsFlag flags) - { - var gpuGetConnectedDisplayIds = - DelegateFactory.GetDelegate(); - - if (!gpuGetConnectedDisplayIds.Accepts().Contains(typeof(DisplayIdsV2))) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - uint count = 0; - var status = gpuGetConnectedDisplayIds(gpuHandle, ValueTypeArray.Null, ref count, flags); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (count == 0) - { - return new DisplayIdsV2[0]; - } - - using ( - var displayIds = - ValueTypeArray.FromArray(typeof(DisplayIdsV2).Instantiate().Repeat((int) count))) - { - status = gpuGetConnectedDisplayIds(gpuHandle, displayIds, ref count, flags); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayIds.ToArray((int) count); - } - } - - /// - /// This API converts a Physical GPU handle and output ID to a display ID. - /// - /// Handle to the physical GPU - /// Connected display output identification on the target GPU - must only have one bit set - /// Display identification - /// Status.ApiNotInitialized: NVAPI not initialized - /// Status.Error: miscellaneous error occurred - /// Status.InvalidArgument: Invalid input parameter. - public static uint GetDisplayIdFromGPUAndOutputId(PhysicalGPUHandle gpuHandle, OutputId outputId) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - outputId, out var display); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return display; - } - - /// - /// This function returns the EDID data for the specified GPU handle and connection bit mask. - /// outputId should have exactly 1 bit set to indicate a single display. - /// - /// Physical GPU handle to check outputs - /// Output identification - /// EDID offset - /// EDID read identification for multi part read, or zero for first run - /// Whole or a part of the EDID data - /// This operation is not supported. - /// - /// Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits - /// set - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - /// Status.DataNotFound: The requested display does not contain an EDID. - /// A delegate callback throws an exception. - // ReSharper disable once TooManyArguments - public static EDIDV3 GetEDID( - PhysicalGPUHandle gpuHandle, - OutputId outputId, - int offset, - int readIdentification = 0) - { - var gpuGetEDID = DelegateFactory.GetDelegate(); - - if (!gpuGetEDID.Accepts().Contains(typeof(EDIDV3))) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - var instance = EDIDV3.CreateWithOffset((uint) readIdentification, (uint) offset); - - using (var edidReference = ValueTypeReference.FromValueType(instance)) - { - var status = gpuGetEDID(gpuHandle, outputId, edidReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return edidReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// This function returns the EDID data for the specified GPU handle and connection bit mask. - /// outputId should have exactly 1 bit set to indicate a single display. - /// - /// Physical GPU handle to check outputs - /// Output identification - /// Whole or a part of the EDID data - /// This operation is not supported. - /// - /// Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits - /// set - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - /// Status.DataNotFound: The requested display does not contain an EDID. - /// A delegate callback throws an exception. - public static IEDID GetEDID(PhysicalGPUHandle gpuHandle, OutputId outputId) - { - var gpuGetEDID = DelegateFactory.GetDelegate(); - - foreach (var acceptType in gpuGetEDID.Accepts()) - { - using (var edidReference = ValueTypeReference.FromValueType(acceptType.Instantiate(), acceptType) - ) - { - var status = gpuGetEDID(gpuHandle, outputId, edidReference); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return edidReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API converts a display ID to a Physical GPU handle and output ID. - /// - /// Display identification of display to retrieve GPU and outputId for - /// Handle to the physical GPU - /// Connected display output identification on the target GPU will only have one bit set. - /// Status.ApiNotInitialized: NVAPI not initialized - /// Status.Error: Miscellaneous error occurred - /// Status.InvalidArgument: Invalid input parameter - /// - /// Status.IdOutOfRange: The DisplayId corresponds to a display which is not within - /// the normal outputId range. - /// - public static OutputId GetGPUAndOutputIdFromDisplayId(uint displayId, out PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()( - displayId, - out gpuHandle, out var outputId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return outputId; - } - - /// - /// This function returns the logical GPU handle associated with the specified display. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// display can be DisplayHandle.DefaultHandle or a handle enumerated from EnumNVidiaDisplayHandle(). - /// - /// Display handle to get information about - /// Logical GPU handle associated with the specified display - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static LogicalGPUHandle GetLogicalGPUFromDisplay(DisplayHandle display) - { - var status = - DelegateFactory.GetDelegate()(display, out var gpu); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpu; - } - - /// - /// This function returns the output type. User can either specify both 'physical GPU handle and outputId (exactly 1 - /// bit set)' or a valid displayId in the outputId parameter. - /// - /// GPU handle to get information about - /// Output identification of the output to get information about - /// Type of the output - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static OutputType GetOutputType(PhysicalGPUHandle gpuHandle, OutputId outputId) - { - return GetOutputType(gpuHandle, (uint) outputId); - } - - /// - /// This function returns the output type. User can either specify both 'physical GPU handle and outputId (exactly 1 - /// bit set)' or a valid displayId in the outputId parameter. - /// - /// GPU handle to get information about - /// Display identification of the divide to get information about - /// Type of the output - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static OutputType GetOutputType(PhysicalGPUHandle gpuHandle, uint displayId) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, displayId, - out var type); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return type; - } - - /// - /// This API retrieves the Physical GPU handle of the connected display - /// - /// Display identification of display to retrieve GPU handle - /// Handle to the physical GPU - /// Status.ApiNotInitialized: NVAPI not initialized - /// Status.Error: Miscellaneous error occurred - /// Status.InvalidArgument: Invalid input parameter - public static PhysicalGPUHandle GetPhysicalGPUFromDisplayId(uint displayId) - { - var status = - DelegateFactory.GetDelegate()(displayId, - out var gpu); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpu; - } - - /// - /// This function returns a physical GPU handle associated with the specified unattached display. - /// The source GPU is a physical render GPU which renders the frame buffer but may or may not drive the scan out. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// - /// Display handle to get information about - /// Physical GPU handle associated with the specified unattached display. - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static PhysicalGPUHandle GetPhysicalGPUFromUnAttachedDisplay(UnAttachedDisplayHandle display) - { - var status = - DelegateFactory.GetDelegate()(display, - out var gpu); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpu; - } - - /// - /// This function returns an array of physical GPU handles associated with the specified display. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// If the display corresponds to more than one physical GPU, the first GPU returned is the one with the attached - /// active output. - /// - /// Display handle to get information about - /// An array of physical GPU handles - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static PhysicalGPUHandle[] GetPhysicalGPUsFromDisplay(DisplayHandle display) - { - var gpuList = - typeof(PhysicalGPUHandle).Instantiate().Repeat(PhysicalGPUHandle.MaxPhysicalGPUs); - var status = DelegateFactory.GetDelegate()(display, gpuList, - out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuList.Take((int) count).ToArray(); - } - - /// - /// Thus function sets the EDID data for the specified GPU handle and connection bit mask. - /// User can either send (Gpu handle and output id) or only display Id in variable outputId parameter and gpuHandle - /// parameter can be default handle. - /// Note: The EDID will be cached across the boot session and will be enumerated to the OS in this call. To remove the - /// EDID set size of EDID to zero. OS and NVAPI connection status APIs will reflect the newly set or removed EDID - /// dynamically. - /// This feature will NOT be supported on the following boards: GeForce, Quadro VX, Tesla - /// - /// Physical GPU handle to check outputs - /// Output identification - /// EDID information - /// This operation is not supported. - /// - /// Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits - /// set - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - /// Status.NotSupported: For the above mentioned GPUs - public static void SetEDID(PhysicalGPUHandle gpuHandle, OutputId outputId, IEDID edid) - { - SetEDID(gpuHandle, (uint) outputId, edid); - } - - /// - /// Thus function sets the EDID data for the specified GPU handle and connection bit mask. - /// User can either send (Gpu handle and output id) or only display Id in variable outputId parameter and gpuHandle - /// parameter can be default handle. - /// Note: The EDID will be cached across the boot session and will be enumerated to the OS in this call. To remove the - /// EDID set size of EDID to zero. OS and NVAPI connection status APIs will reflect the newly set or removed EDID - /// dynamically. - /// This feature will NOT be supported on the following boards: GeForce, Quadro VX, Tesla - /// - /// Physical GPU handle to check outputs - /// Output identification - /// EDID information - /// This operation is not supported. - /// - /// Status.InvalidArgument: gpuHandle or edid is invalid, outputId has 0 or > 1 bits - /// set - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - /// Status.NotSupported: For the above mentioned GPUs - /// A delegate callback throws an exception. - public static void SetEDID(PhysicalGPUHandle gpuHandle, uint displayId, IEDID edid) - { - var gpuSetEDID = DelegateFactory.GetDelegate(); - - if (!gpuSetEDID.Accepts().Contains(edid.GetType())) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - using (var edidReference = ValueTypeReference.FromValueType(edid, edid.GetType())) - { - var status = gpuSetEDID(gpuHandle, displayId, edidReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This function determines if a set of GPU outputs can be active simultaneously. While a GPU may have 'n' outputs, - /// typically they cannot all be active at the same time due to internal resource sharing. - /// Given a physical GPU handle and a mask of candidate outputs, this call will return true if all of the specified - /// outputs can be driven simultaneously. It will return false if they cannot. - /// - /// Physical GPU handle to check outputs - /// Output identification combination - /// true if all of the specified outputs can be driven simultaneously. It will return false if they cannot. - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static bool ValidateOutputCombination(PhysicalGPUHandle gpuHandle, OutputId outputIds) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, outputIds); - - if (status == Status.InvalidCombination) - { - return false; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return true; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.Illumination.cs b/app/NvAPIWrapper/Native/GPUApi.Illumination.cs deleted file mode 100644 index 46d3aeb0..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.Illumination.cs +++ /dev/null @@ -1,246 +0,0 @@ -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// Gets the control information about illumination devices on the given GPU. - /// - /// The physical GPU handle. - /// An instance of . - public static IlluminationDeviceControlParametersV1 ClientIlluminationDevicesGetControl( - PhysicalGPUHandle gpuHandle) - { - var instance = typeof(IlluminationDeviceControlParametersV1) - .Instantiate(); - - using (var deviceControlParametersReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - deviceControlParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return deviceControlParametersReference.ToValueType() - .GetValueOrDefault(); - } - } - - /// - /// Returns static information about illumination devices on the given GPU. - /// - /// The physical GPU handle. - /// An instance of . - public static IlluminationDeviceInfoParametersV1 ClientIlluminationDevicesGetInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(IlluminationDeviceInfoParametersV1).Instantiate(); - - using (var deviceInfoParametersReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - deviceInfoParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return deviceInfoParametersReference.ToValueType() - .GetValueOrDefault(); - } - } - - /// - /// Sets the control information about illumination devices on the given GPU. - /// - /// The physical GPU handle. - /// The new control illumination devices control information. - public static void ClientIlluminationDevicesSetControl( - PhysicalGPUHandle gpuHandle, - IlluminationDeviceControlParametersV1 deviceControlParameters) - { - using (var deviceControlParametersReference = ValueTypeReference.FromValueType(deviceControlParameters)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - deviceControlParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// Gets the control information about illumination zones on the given GPU. - /// - /// The physical GPU handle. - /// The type of settings to retrieve. - /// An instance of . - public static IlluminationZoneControlParametersV1 ClientIlluminationZonesGetControl( - PhysicalGPUHandle gpuHandle, - IlluminationZoneControlValuesType valuesType) - { - var instance = new IlluminationZoneControlParametersV1(valuesType); - - using (var zoneControlParametersReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - zoneControlParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return zoneControlParametersReference.ToValueType() - .GetValueOrDefault(); - } - } - - /// - /// Returns static information about illumination zones on the given GPU. - /// - /// The physical GPU handle. - /// An instance of . - public static IlluminationZoneInfoParametersV1 ClientIlluminationZonesGetInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(IlluminationZoneInfoParametersV1).Instantiate(); - - using (var zoneInfoParametersReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - zoneInfoParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return zoneInfoParametersReference.ToValueType().GetValueOrDefault(); - } - } - - /// - /// Sets the control information about illumination zones on the given GPU. - /// - /// The physical GPU handle. - /// The new control illumination zones control information. - public static void ClientIlluminationZonesSetControl( - PhysicalGPUHandle gpuHandle, - IlluminationZoneControlParametersV1 zoneControlParameters) - { - using (var zoneControlParametersReference = ValueTypeReference.FromValueType(zoneControlParameters)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - zoneControlParametersReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// Reports value of the specified illumination attribute brightness. - /// - /// The physical GPU handle. - /// The attribute to get the value of. - /// Brightness value in percentage. - public static uint GetIllumination(PhysicalGPUHandle gpuHandle, IlluminationAttribute attribute) - { - var instance = new GetIlluminationParameterV1(gpuHandle, attribute); - - using (var getParameterReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - getParameterReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return getParameterReference.ToValueType() - .GetValueOrDefault() - .ValueInPercentage; - } - } - - /// - /// Queries a illumination attribute support status. - /// - /// The physical GPU handle. - /// The attribute to get the support status of. - /// true if the attribute is supported on this GPU; otherwise false. - public static bool QueryIlluminationSupport(PhysicalGPUHandle gpuHandle, IlluminationAttribute attribute) - { - var instance = new QueryIlluminationSupportParameterV1(gpuHandle, attribute); - - using (var querySupportParameterReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - querySupportParameterReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return querySupportParameterReference.ToValueType() - .GetValueOrDefault() - .IsSupported; - } - } - - /// - /// Sets the value of the specified illumination attribute brightness. - /// - /// The physical GPU handle. - /// The attribute to set the value of. - /// Brightness value in percentage. - public static void SetIllumination( - PhysicalGPUHandle gpuHandle, - IlluminationAttribute attribute, - uint valueInPercentage) - { - var instance = new SetIlluminationParameterV1(gpuHandle, attribute, valueInPercentage); - - using (var setParameterReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - setParameterReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.Performance.cs b/app/NvAPIWrapper/Native/GPUApi.Performance.cs deleted file mode 100644 index 06ce3ee4..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.Performance.cs +++ /dev/null @@ -1,527 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// [PRIVATE] - /// Enables the overclocked performance states - /// - /// The handle of the GPU to perform the operation on. - public static void EnableOverclockedPStates(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function retrieves the clock frequencies information from an specific physical GPU and fills the structure - /// - /// - /// Handle of the physical GPU for which the clock frequency information is to be - /// retrieved. - /// - /// - /// The structure that holds options for the operations and should be filled with the - /// results, use null to return current clock frequencies - /// - /// The device clock frequencies information. - /// This operation is not supported. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// A delegate callback throws an exception. - public static IClockFrequencies GetAllClockFrequencies( - PhysicalGPUHandle physicalGPUHandle, - IClockFrequencies clockFrequencyOptions = null) - { - var getClocksInfo = DelegateFactory.GetDelegate(); - - if (clockFrequencyOptions == null) - { - foreach (var acceptType in getClocksInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var clockFrequenciesInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getClocksInfo(physicalGPUHandle, clockFrequenciesInfo); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockFrequenciesInfo.ToValueType(acceptType); - } - } - } - else - { - using (var clockFrequenciesInfo = - ValueTypeReference.FromValueType(clockFrequencyOptions, clockFrequencyOptions.GetType())) - { - var status = getClocksInfo(physicalGPUHandle, clockFrequenciesInfo); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockFrequenciesInfo.ToValueType(clockFrequencyOptions.GetType()); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the clock boost lock for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The GPU clock boost lock. - public static PrivateClockBoostLockV2 GetClockBoostLock(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateClockBoostLockV2).Instantiate(); - - using (var clockLockReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockLockReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockLockReference.ToValueType(typeof(PrivateClockBoostLockV2)); - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the clock boost mask for passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The GPI clock boost mask. - public static PrivateClockBoostMasksV1 GetClockBoostMask(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateClockBoostMasksV1).Instantiate(); - - using (var clockBoostReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockBoostReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockBoostReference.ToValueType(typeof(PrivateClockBoostMasksV1)); - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the clock boost ranges for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The GPU clock boost ranges. - public static PrivateClockBoostRangesV1 GetClockBoostRanges(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateClockBoostRangesV1).Instantiate(); - - using (var clockRangesReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockRangesReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockRangesReference.ToValueType(typeof(PrivateClockBoostRangesV1)); - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the clock boost table for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The GPU clock boost table. - public static PrivateClockBoostTableV1 GetClockBoostTable(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateClockBoostTableV1).Instantiate(); - - using (var clockTableReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockTableReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return clockTableReference.ToValueType(typeof(PrivateClockBoostTableV1)); - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the core voltage boost percentage for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The voltage boost percentage. - public static PrivateVoltageBoostPercentV1 GetCoreVoltageBoostPercent(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateVoltageBoostPercentV1).Instantiate(); - - using (var voltageBoostReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - voltageBoostReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return voltageBoostReference.ToValueType( - typeof(PrivateVoltageBoostPercentV1)); - } - } - - /// - /// This function returns the current performance state (P-State). - /// - /// GPU handle to get information about - /// The current performance state. - /// Status.InvalidArgument: gpuHandle is NULL - public static PerformanceStateId GetCurrentPerformanceState(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - out var performanceState); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return performanceState; - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the current voltage status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The voltage status of the GPU. - public static PrivateVoltageStatusV1 GetCurrentVoltage(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateVoltageStatusV1).Instantiate(); - - using (var voltageStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - voltageStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return voltageStatusReference.ToValueType(typeof(PrivateVoltageStatusV1)); - } - } - - /// - /// This function retrieves all available performance states (P-States) information. - /// P-States are GPU active/executing performance capability and power consumption states. - /// - /// GPU handle to get information about. - /// Flag to get specific information about a performance state. - /// Retrieved performance states information - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IPerformanceStatesInfo GetPerformanceStates( - PhysicalGPUHandle physicalGPUHandle, - GetPerformanceStatesInfoFlags flags) - { - var getPerformanceStatesInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getPerformanceStatesInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var performanceStateInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getPerformanceStatesInfo(physicalGPUHandle, performanceStateInfo, flags); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return performanceStateInfo.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This function retrieves all available performance states (P-States) 2.0 information. - /// P-States are GPU active/executing performance capability and power consumption states. - /// - /// GPU handle to get information about. - /// Retrieved performance states 2.0 information - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - [SuppressMessage("ReSharper", "EventExceptionNotDocumented")] - public static IPerformanceStates20Info GetPerformanceStates20(PhysicalGPUHandle physicalGPUHandle) - { - var getPerformanceStates20 = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getPerformanceStates20.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var performanceStateInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getPerformanceStates20(physicalGPUHandle, performanceStateInfo); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return performanceStateInfo.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Gets the GPU boost frequency curve controls for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The retrieved VFP curve. - public static PrivateVFPCurveV1 GetVFPCurve(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateVFPCurveV1).Instantiate(); - - using (var vfpCurveReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - vfpCurveReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return vfpCurveReference.ToValueType(typeof(PrivateVFPCurveV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the performance policies current information for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The performance policies information. - public static PrivatePerformanceInfoV1 PerformancePoliciesGetInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePerformanceInfoV1).Instantiate(); - - using (var performanceInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - performanceInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return performanceInfoReference.ToValueType(typeof(PrivatePerformanceInfoV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the performance policies status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The performance policies status of the GPU. - public static PrivatePerformanceStatusV1 PerformancePoliciesGetStatus(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePerformanceStatusV1).Instantiate(); - - using (var performanceStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - performanceStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return performanceStatusReference.ToValueType( - typeof(PrivatePerformanceStatusV1)); - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Sets the clock boost lock status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The new clock boost lock status. - public static void SetClockBoostLock(PhysicalGPUHandle gpuHandle, PrivateClockBoostLockV2 clockBoostLock) - { - using (var clockLockReference = ValueTypeReference.FromValueType(clockBoostLock)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockLockReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Sets the clock boost table for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The new clock table. - public static void SetClockBoostTable(PhysicalGPUHandle gpuHandle, PrivateClockBoostTableV1 clockBoostTable) - { - using (var clockTableReference = ValueTypeReference.FromValueType(clockBoostTable)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - clockTableReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - [Pascal Only] - /// Sets the core voltage boost percentage - /// - /// The handle of the GPU to perform the operation on. - /// The voltage boost percentages. - public static void SetCoreVoltageBoostPercent( - PhysicalGPUHandle gpuHandle, - PrivateVoltageBoostPercentV1 boostPercent) - { - using (var boostPercentReference = ValueTypeReference.FromValueType(boostPercent)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - boostPercentReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - /// This function sets the performance states (P-States) 2.0 information. - /// P-States are GPU active/executing performance capability and power consumption states. - /// - /// GPU handle to get information about. - /// Performance status 2.0 information to set - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static void SetPerformanceStates20( - PhysicalGPUHandle physicalGPUHandle, - IPerformanceStates20Info performanceStates20Info) - { - using (var performanceStateInfo = - ValueTypeReference.FromValueType(performanceStates20Info, performanceStates20Info.GetType())) - { - var status = DelegateFactory.GetDelegate()( - physicalGPUHandle, - performanceStateInfo - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.PowerPolicies.cs b/app/NvAPIWrapper/Native/GPUApi.PowerPolicies.cs deleted file mode 100644 index 21322c31..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.PowerPolicies.cs +++ /dev/null @@ -1,115 +0,0 @@ -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// [PRIVATE] - /// Gets the current power policies information for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The current power policies information. - public static PrivatePowerPoliciesInfoV1 ClientPowerPoliciesGetInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePowerPoliciesInfoV1).Instantiate(); - - using (var policiesInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - policiesInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesInfoReference.ToValueType( - typeof(PrivatePowerPoliciesInfoV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the power policies status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The power policies status. - public static PrivatePowerPoliciesStatusV1 ClientPowerPoliciesGetStatus(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePowerPoliciesStatusV1).Instantiate(); - - using (var policiesStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesStatusReference.ToValueType( - typeof(PrivatePowerPoliciesStatusV1)); - } - } - - /// - /// [PRIVATE] - /// Sets the power policies status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The new power limiter policy. - public static void ClientPowerPoliciesSetStatus( - PhysicalGPUHandle gpuHandle, - PrivatePowerPoliciesStatusV1 policiesStatus) - { - using (var policiesStatusReference = ValueTypeReference.FromValueType(policiesStatus)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - /// Gets the power topology status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The power topology status. - public static PrivatePowerTopologiesStatusV1 ClientPowerTopologyGetStatus(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePowerTopologiesStatusV1).Instantiate(); - - using (var topologiesStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - topologiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return topologiesStatusReference.ToValueType( - typeof(PrivatePowerTopologiesStatusV1)); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.Thermal.cs b/app/NvAPIWrapper/Native/GPUApi.Thermal.cs deleted file mode 100644 index 16fe5fc2..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.Thermal.cs +++ /dev/null @@ -1,449 +0,0 @@ -using System; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// [PRIVATE] - /// Gets the cooler policy table for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The cooler policy to get the table for. - /// The cooler index. - /// Number of policy table entries retrieved. - /// The cooler policy table for the GPU. - // ReSharper disable once TooManyArguments - public static PrivateCoolerPolicyTableV1 GetCoolerPolicyTable( - PhysicalGPUHandle gpuHandle, - CoolerPolicy policy, - uint index, - out uint count) - { - var instance = typeof(PrivateCoolerPolicyTableV1).Instantiate(); - instance._Policy = policy; - - using (var policyTableReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - index, - policyTableReference, - out count - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policyTableReference.ToValueType(typeof(PrivateCoolerPolicyTableV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the cooler settings for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The cooler targets to get settings. - /// The cooler settings. - public static PrivateCoolerSettingsV1 GetCoolerSettings( - PhysicalGPUHandle gpuHandle, - CoolerTarget coolerTarget = CoolerTarget.All) - { - var instance = typeof(PrivateCoolerSettingsV1).Instantiate(); - - using (var coolerSettingsReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - coolerTarget, - coolerSettingsReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return coolerSettingsReference.ToValueType(typeof(PrivateCoolerSettingsV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the current fan speed level for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The current fan speed level. - public static uint GetCurrentFanSpeedLevel(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory - .GetDelegate()(gpuHandle, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return count; - } - - /// - /// [PRIVATE] - /// Gets the current thermal level for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The current thermal level. - public static uint GetCurrentThermalLevel(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return count; - } - - /// - /// This function returns the fan speed tachometer reading for the specified physical GPU. - /// - /// Physical GPU handle to get tachometer reading from - /// The GPU fan speed in revolutions per minute. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static uint GetTachReading(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, out var value - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return value; - } - - /// - /// [PRIVATE] - /// Gets the current thermal policies information for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The current thermal policies information. - public static PrivateThermalPoliciesInfoV2 GetThermalPoliciesInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateThermalPoliciesInfoV2).Instantiate(); - - using (var policiesInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - policiesInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesInfoReference.ToValueType( - typeof(PrivateThermalPoliciesInfoV2)); - } - } - - /// - /// [PRIVATE] - /// Gets the thermal policies status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The thermal policies status. - public static PrivateThermalPoliciesStatusV2 GetThermalPoliciesStatus(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateThermalPoliciesStatusV2).Instantiate(); - - using (var policiesStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesStatusReference.ToValueType( - typeof(PrivateThermalPoliciesStatusV2)); - } - } - - /// - /// This function retrieves the thermal information of all thermal sensors or specific thermal sensor associated with - /// the selected GPU. To retrieve info for all sensors, set sensorTarget to ThermalSettingsTarget.All. - /// - /// Handle of the physical GPU for which the memory information is to be extracted. - /// Specifies the requested thermal sensor target. - /// The device thermal sensors information. - /// This operation is not supported. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// A delegate callback throws an exception. - public static IThermalSettings GetThermalSettings( - PhysicalGPUHandle physicalGPUHandle, - ThermalSettingsTarget sensorTarget = ThermalSettingsTarget.All) - { - var getThermalSettings = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getThermalSettings.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var gpuThermalSettings = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getThermalSettings(physicalGPUHandle, sensorTarget, gpuThermalSettings); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuThermalSettings.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// [PRIVATE] - /// Restores the cooler policy table to default for the passed GPU handle and cooler index. - /// - /// The handle of the GPU to perform the operation on. - /// The cooler policy to restore to default. - /// The indexes of the coolers to restore their policy tables to default. - public static void RestoreCoolerPolicyTable( - PhysicalGPUHandle gpuHandle, - CoolerPolicy policy, - uint[] indexes = null) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - indexes, - (uint) (indexes?.Length ?? 0), - policy - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// [PRIVATE] - /// Restores the cooler settings to default for the passed GPU handle and cooler index. - /// - /// The handle of the GPU to perform the operation on. - /// The indexes of the coolers to restore their settings to default. - public static void RestoreCoolerSettings( - PhysicalGPUHandle gpuHandle, - uint[] indexes = null) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - indexes, - (uint) (indexes?.Length ?? 0) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// [PRIVATE] - /// Sets the cooler levels for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The cooler index. - /// The cooler level information. - /// The number of entries in the cooler level information. - // ReSharper disable once TooManyArguments - public static void SetCoolerLevels( - PhysicalGPUHandle gpuHandle, - uint index, - PrivateCoolerLevelsV1 coolerLevels, - uint levelsCount - ) - { - using (var coolerLevelsReference = ValueTypeReference.FromValueType(coolerLevels)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - index, - coolerLevelsReference, - levelsCount - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - /// Sets the cooler policy table for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The cooler index. - /// The cooler policy table. - /// The number of entries in the cooler policy table. - // ReSharper disable once TooManyArguments - public static void SetCoolerPolicyTable( - PhysicalGPUHandle gpuHandle, - uint index, - PrivateCoolerPolicyTableV1 coolerPolicyTable, - uint policyLevelsCount - ) - { - var instance = typeof(PrivateCoolerPolicyTableV1).Instantiate(); - - using (var policyTableReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - index, - policyTableReference, - policyLevelsCount - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// [PRIVATE] - /// Sets the thermal policies status for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The new thermal limiter policy to apply. - public static void SetThermalPoliciesStatus( - PhysicalGPUHandle gpuHandle, - PrivateThermalPoliciesStatusV2 thermalPoliciesStatus) - { - using (var policiesStatusReference = ValueTypeReference.FromValueType(thermalPoliciesStatus)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - public static PrivateFanCoolersInfoV1 GetClientFanCoolersInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateFanCoolersInfoV1).Instantiate(); - - using (var policiesInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - policiesInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesInfoReference.ToValueType( - typeof(PrivateFanCoolersInfoV1)); - } - } - - public static PrivateFanCoolersStatusV1 GetClientFanCoolersStatus(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateFanCoolersStatusV1).Instantiate(); - - using (var policiesStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesStatusReference.ToValueType( - typeof(PrivateFanCoolersStatusV1)); - } - } - - public static PrivateFanCoolersControlV1 GetClientFanCoolersControl(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateFanCoolersControlV1).Instantiate(); - using (var policiesStatusReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - policiesStatusReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return policiesStatusReference.ToValueType( - typeof(PrivateFanCoolersControlV1)); - } - } - - public static void SetClientFanCoolersControl(PhysicalGPUHandle gpuHandle, PrivateFanCoolersControlV1 control) - { - using (var coolerLevelsReference = ValueTypeReference.FromValueType(control)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - coolerLevelsReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.Usage.cs b/app/NvAPIWrapper/Native/GPUApi.Usage.cs deleted file mode 100644 index 4fdcff11..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.Usage.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; - -namespace NvAPIWrapper.Native -{ - public static partial class GPUApi - { - /// - /// [PRIVATE] - /// Enables the dynamic performance states - /// - /// The handle of the GPU to perform the operation on. - public static void EnableDynamicPStates(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function retrieves the dynamic performance states information from specific GPU - /// - /// Handle of the physical GPU for which the memory information is to be extracted. - /// The device utilizations information array. - /// This operation is not supported. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// A delegate callback throws an exception. - public static DynamicPerformanceStatesInfoV1 GetDynamicPerformanceStatesInfoEx( - PhysicalGPUHandle physicalGPUHandle) - { - var getDynamicPerformanceStatesInfoEx = - DelegateFactory.GetDelegate(); - - foreach (var acceptType in getDynamicPerformanceStatesInfoEx.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var gpuDynamicPStateInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getDynamicPerformanceStatesInfoEx(physicalGPUHandle, gpuDynamicPStateInfo); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuDynamicPStateInfo.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// Gets the reason behind the current decrease in performance. - /// - /// The handle of the GPU to perform the operation on. - /// A value indicating the reason of current performance decrease. - public static PerformanceDecreaseReason GetPerformanceDecreaseInfo(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - out var decreaseReason - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return decreaseReason; - } - - /// - /// [PRIVATE] - /// Gets the GPU usage metrics for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The usage information for the selected GPU. - public static PrivateUsagesInfoV1 GetUsages(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateUsagesInfoV1).Instantiate(); - - using (var usageInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - usageInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return usageInfoReference.ToValueType(typeof(PrivateUsagesInfoV1)); - } - } - - /// - /// Queries active applications. - /// - /// The physical GPU handle. - /// The list of active applications. - public static PrivateActiveApplicationV2[] QueryActiveApps(PhysicalGPUHandle gpuHandle) - { - var queryActiveApps = DelegateFactory.GetDelegate(); - - // ReSharper disable once EventExceptionNotDocumented - if (!queryActiveApps.Accepts().Contains(typeof(PrivateActiveApplicationV2))) - { - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - uint count = PrivateActiveApplicationV2.MaximumNumberOfApplications; - var instances = typeof(PrivateActiveApplicationV2).Instantiate() - .Repeat((int) count); - - using (var applications = ValueTypeArray.FromArray(instances)) - { - // ReSharper disable once EventExceptionNotDocumented - var status = queryActiveApps(gpuHandle, applications, ref count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return applications.ToArray((int) count); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GPUApi.cs b/app/NvAPIWrapper/Native/GPUApi.cs deleted file mode 100644 index 77e766eb..00000000 --- a/app/NvAPIWrapper/Native/GPUApi.cs +++ /dev/null @@ -1,1197 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains GPU static functions - /// - // ReSharper disable once ClassTooBig - public static partial class GPUApi - { - /// - /// This function returns an array of logical GPU handles. - /// Each handle represents one or more GPUs acting in concert as a single graphics device. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// All logical GPUs handles get invalidated on a GPU topology change, so the calling application is required to - /// re-enum - /// the logical GPU handles to get latest physical handle mapping after every GPU topology change activated by a call - /// to SetGpuTopologies(). - /// To detect if SLI rendering is enabled, use Direct3DApi.GetCurrentSLIState(). - /// - /// Array of logical GPU handles. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static LogicalGPUHandle[] EnumLogicalGPUs() - { - var gpuList = - typeof(LogicalGPUHandle).Instantiate().Repeat(LogicalGPUHandle.MaxLogicalGPUs); - var status = DelegateFactory.GetDelegate()(gpuList, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuList.Take((int) count).ToArray(); - } - - /// - /// This function returns an array of physical GPU handles. - /// Each handle represents a physical GPU present in the system. - /// That GPU may be part of an SLI configuration, or may not be visible to the OS directly. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// Note: In drivers older than 105.00, all physical GPU handles get invalidated on a mode-set. So the calling - /// applications need to re-enum the handles after every mode-set. With drivers 105.00 and up, all physical GPU handles - /// are constant. Physical GPU handles are constant as long as the GPUs are not physically moved and the SBIOS VGA - /// order is unchanged. - /// For GPU handles in TCC MODE please use EnumTCCPhysicalGPUs() - /// - /// - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static PhysicalGPUHandle[] EnumPhysicalGPUs() - { - var gpuList = - typeof(PhysicalGPUHandle).Instantiate().Repeat(PhysicalGPUHandle.PhysicalGPUs); - var status = DelegateFactory.GetDelegate()(gpuList, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuList.Take((int) count).ToArray(); - } - - /// - /// This function returns an array of physical GPU handles that are in TCC Mode. - /// Each handle represents a physical GPU present in the system in TCC Mode. - /// That GPU may not be visible to the OS directly. - /// NOTE: Handles enumerated by this API are only valid for NvAPIs that are tagged as TCC_SUPPORTED If handle is passed - /// to any other API, it will fail with Status.InvalidHandle - /// For WDDM GPU handles please use EnumPhysicalGPUs() - /// - /// An array of physical GPU handles that are in TCC Mode. - /// See NVIDIAApiException.Status for the reason of the exception. - public static PhysicalGPUHandle[] EnumTCCPhysicalGPUs() - { - var gpuList = - typeof(PhysicalGPUHandle).Instantiate().Repeat(PhysicalGPUHandle.PhysicalGPUs); - var status = DelegateFactory.GetDelegate()(gpuList, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuList.Take((int) count).ToArray(); - } - - /// - /// This function returns the AGP aperture in megabytes. - /// - /// Physical GPU handle to get information about - /// AGP aperture in megabytes - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static int GetAGPAperture(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var agpAperture); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) agpAperture; - } - - /// - /// [PRIVATE] - /// Gets the architect information for the passed physical GPU handle. - /// - /// The GPU handle to retrieve information for. - /// The GPU architect information. - public static PrivateArchitectInfoV2 GetArchitectInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivateArchitectInfoV2).Instantiate(); - - using (var architectInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - architectInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return architectInfoReference.ToValueType( - typeof(PrivateArchitectInfoV2)); - } - } - - /// - /// This API Retrieves the Board information (a unique GPU Board Serial Number) stored in the InfoROM. - /// - /// Physical GPU Handle - /// Board Information - /// Status.Error: Miscellaneous error occurred - /// Status.ExpectedPhysicalGPUHandle: Handle passed is not a physical GPU handle - /// Status.ApiNotInitialized: NVAPI not initialized - public static BoardInfo GetBoardInfo(PhysicalGPUHandle gpuHandle) - { - var boardInfo = typeof(BoardInfo).Instantiate(); - var status = DelegateFactory.GetDelegate()(gpuHandle, ref boardInfo); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return boardInfo; - } - - /// - /// Returns the identification of the bus associated with this GPU. - /// - /// GPU handle to get information about - /// Id of the bus - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static int GetBusId(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var busId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) busId; - } - - /// - /// Returns the identification of the bus slot associated with this GPU. - /// - /// GPU handle to get information about - /// Identification of the bus slot associated with this GPU - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static int GetBusSlotId(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var busId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) busId; - } - - /// - /// This function returns the type of bus associated with this GPU. - /// TCC_SUPPORTED - /// - /// GPU handle to get information about - /// Type of bus associated with this GPU - /// Status.InvalidArgument: gpuHandle is NULL - public static GPUBusType GetBusType(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var busType); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return busType; - } - - /// - /// This function returns the current AGP Rate (0 = AGP not present, 1 = 1x, 2 = 2x, etc.). - /// - /// Physical GPU handle to get information about - /// Current AGP rate - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static int GetCurrentAGPRate(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var agpRate); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) agpRate; - } - - /// - /// This function returns the number of PCIE lanes being used for the PCIE interface downstream from the GPU. - /// - /// Physical GPU handle to get information about - /// PCIE lanes being used for the PCIE interface downstream - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static int GetCurrentPCIEDownStreamWidth(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, - out var width); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) width; - } - - /// - /// [PRIVATE] - /// Gets the driver model for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The driver model of the GPU. - public static uint GetDriverModel(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return count; - } - - /// - /// This function returns ECC memory configuration information. - /// - /// - /// handle identifying the physical GPU for which ECC configuration information is to be - /// retrieved. - /// - /// An instance of - public static ECCConfigurationInfoV1 GetECCConfigurationInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(ECCConfigurationInfoV1).Instantiate(); - - using (var configurationInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - configurationInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return configurationInfoReference.ToValueType(typeof(ECCConfigurationInfoV1)); - } - } - - /// - /// This function returns ECC memory error information. - /// - /// A handle identifying the physical GPU for which ECC error information is to be retrieved. - /// An instance of - public static ECCErrorInfoV1 GetECCErrorInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(ECCErrorInfoV1).Instantiate(); - - using (var errorInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - errorInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return errorInfoReference.ToValueType(typeof(ECCErrorInfoV1)); - } - } - - /// - /// This function returns ECC memory status information. - /// - /// A handle identifying the physical GPU for which ECC status information is to be retrieved. - /// An instance of - public static ECCStatusInfoV1 GetECCStatusInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(ECCStatusInfoV1).Instantiate(); - - using (var statusInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - statusInfoReference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return statusInfoReference.ToValueType(typeof(ECCStatusInfoV1)); - } - } - - /// - /// [PRIVATE] - /// Gets the GPU manufacturing foundry of the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The GPU manufacturing foundry of the GPU. - public static GPUFoundry GetFoundry(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var foundry); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return foundry; - } - - /// - /// [PRIVATE] - /// Gets the current frame buffer width and location for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The frame buffer width. - /// The frame buffer location. - public static void GetFrameBufferWidthAndLocation( - PhysicalGPUHandle gpuHandle, - out uint width, - out uint location) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out width, - out location); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function retrieves the full GPU name as an ASCII string - for example, "Quadro FX 1400". - /// - /// Physical GPU handle to get information about - /// Full GPU name as an ASCII string - /// See NVIDIAApiException.Status for the reason of the exception. - public static string GetFullName(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var name); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return name.Value; - } - - /// - /// Retrieves the total number of cores defined for a GPU. - /// Returns 0 on architectures that don't define GPU cores. - /// - /// Physical GPU handle to get information about - /// Total number of cores - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - /// Status.NotSupported: API call is not supported on current architecture - public static uint GetGPUCoreCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var cores); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return cores; - } - - /// - /// [PRIVATE] - /// Gets the GPUID of the passed GPU handle. - /// - /// The GPU handle to get the GPUID for. - /// The GPU's GPUID. - public static uint GetGPUIDFromPhysicalGPU(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var gpuId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuId; - } - - /// - /// This function returns the GPU type (integrated or discrete). - /// TCC_SUPPORTED - /// - /// GPU handle to get information about - /// GPU type - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static GPUType GetGPUType(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var type); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return type; - } - - /// - /// This function returns the interrupt number associated with this GPU. - /// - /// GPU handle to get information about - /// Interrupt number associated with this GPU - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static int GetIRQ(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var irq); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) irq; - } - - /// - /// [PRIVATE] - /// Gets the current frame buffer width and location for the passed logical GPU handle. - /// - /// The handle of the logical GPU to perform the operation on. - /// The frame buffer width. - /// The frame buffer location. - public static void GetLogicalFrameBufferWidthAndLocation( - LogicalGPUHandle gpuHandle, - out uint width, - out uint location) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - out width, out location); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function returns the logical GPU handle associated with specified physical GPU handle. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// - /// GPU handle to get information about - /// Logical GPU handle associated with specified physical GPU handle - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - public static LogicalGPUHandle GetLogicalGPUFromPhysicalGPU(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var gpu); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpu; - } - - /// - /// This function retrieves the available driver memory footprint for the specified GPU. - /// If the GPU is in TCC Mode, only dedicatedVideoMemory will be returned. - /// - /// Handle of the physical GPU for which the memory information is to be extracted. - /// The memory footprint available in the driver. - /// This operation is not supported. - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// A delegate callback throws an exception. - public static IDisplayDriverMemoryInfo GetMemoryInfo(PhysicalGPUHandle physicalGPUHandle) - { - var getMemoryInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getMemoryInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var displayDriverMemoryInfo = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getMemoryInfo(physicalGPUHandle, displayDriverMemoryInfo); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displayDriverMemoryInfo.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// [PRIVATE] - /// Gets the number of GPC (Graphic Processing Clusters) of the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// The number of GPC units for the GPU. - public static uint GetPartitionCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return count; - } - - /// - /// [PRIVATE] - /// Gets additional information about the PCIe interface and configuration for the passed GPU handle. - /// - /// The handle of the GPU to perform the operation on. - /// PCIe information and configurations. - public static PrivatePCIeInfoV2 GetPCIEInfo(PhysicalGPUHandle gpuHandle) - { - var instance = typeof(PrivatePCIeInfoV2).Instantiate(); - - using (var pcieInfoReference = ValueTypeReference.FromValueType(instance)) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, pcieInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return pcieInfoReference.ToValueType(typeof(PrivatePCIeInfoV2)); - } - } - - /// - /// This function returns the PCI identifiers associated with this GPU. - /// TCC_SUPPORTED - /// - /// GPU handle to get information about - /// The internal PCI device identifier for the GPU. - /// The internal PCI subsystem identifier for the GPU. - /// The internal PCI device-specific revision identifier for the GPU. - /// The external PCI device identifier for the GPU. - /// Status.InvalidArgument: gpuHandle or an argument is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - // ReSharper disable once TooManyArguments - public static void GetPCIIdentifiers( - PhysicalGPUHandle gpuHandle, - out uint deviceId, - out uint subSystemId, - out uint revisionId, - out uint extDeviceId) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, - out deviceId, - out subSystemId, out revisionId, out extDeviceId); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function returns the physical size of frame buffer in KB. This does NOT include any system RAM that may be - /// dedicated for use by the GPU. - /// TCC_SUPPORTED - /// - /// GPU handle to get information about - /// Physical size of frame buffer in KB - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static int GetPhysicalFrameBufferSize(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - out var size); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) size; - } - - /// - /// [PRIVATE] - /// Gets a physical GPU handle from the passed GPUID - /// - /// The GPUID to get the physical handle for. - /// The retrieved physical GPU handle. - public static PhysicalGPUHandle GetPhysicalGPUFromGPUID(uint gpuId) - { - var status = - DelegateFactory.GetDelegate()(gpuId, out var gpuHandle); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuHandle; - } - - /// - /// This function returns the physical GPU handles associated with the specified logical GPU handle. - /// At least one GPU must be present in the system and running an NVIDIA display driver. - /// - /// Logical GPU handle to get information about - /// An array of physical GPU handles - /// Status.InvalidArgument: gpuHandle is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedLogicalGPUHandle: gpuHandle was not a logical GPU handle - public static PhysicalGPUHandle[] GetPhysicalGPUsFromLogicalGPU(LogicalGPUHandle gpuHandle) - { - var gpuList = - typeof(PhysicalGPUHandle).Instantiate().Repeat(PhysicalGPUHandle.MaxPhysicalGPUs); - var status = DelegateFactory.GetDelegate()(gpuHandle, - gpuList, - out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gpuList.Take((int) count).ToArray(); - } - - /// - /// This function retrieves the Quadro status for the GPU (true if Quadro, false if GeForce) - /// - /// GPU handle to get information about - /// true if Quadro, false if GeForce - /// Status.Error: Miscellaneous error occurred - public static bool GetQuadroStatus(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var isQuadro); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return isQuadro > 0; - } - - /// - /// [PRIVATE] - /// Gets the number of RAM banks for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of RAM memory banks. - public static uint GetRAMBankCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var bankCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return bankCount; - } - - /// - /// [PRIVATE] - /// Gets the RAM bus width for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The RAM memory bus width. - public static uint GetRAMBusWidth(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var busWidth); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return busWidth; - } - - /// - /// [PRIVATE] - /// Gets the RAM maker for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The RAM memory maker. - public static GPUMemoryMaker GetRAMMaker(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var ramMaker); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return ramMaker; - } - - /// - /// [PRIVATE] - /// Gets the RAM type for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The RAM memory type. - public static GPUMemoryType GetRAMType(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var ramType); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return ramType; - } - - /// - /// [PRIVATE] - /// Gets the ROP count for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of ROP units. - public static uint GetROPCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var ropCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return ropCount; - } - - /// - /// [PRIVATE] - /// Gets the number of shader pipe lines for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of shader pipelines. - public static uint GetShaderPipeCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var spCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return spCount; - } - - /// - /// This function retrieves the number of Shader SubPipes on the GPU - /// On newer architectures, this corresponds to the number of SM units - /// - /// GPU handle to get information about - /// Number of Shader SubPipes on the GPU - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static uint GetShaderSubPipeCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var count); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return count; - } - - /// - /// [PRIVATE] - /// Gets the GPU short name (code name) for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The GPU short name. - public static string GetShortName(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, out var name); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return name.Value; - } - - /// - /// This function identifies whether the GPU is a notebook GPU or a desktop GPU. - /// - /// GPU handle to get information about - /// GPU system type - /// Status.InvalidArgument: gpuHandle is NULL - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle - public static SystemType GetSystemType(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var systemType); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return systemType; - } - - /// - /// [PRIVATE] - /// Gets the SM count for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of SM units. - public static uint GetTotalSMCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var smCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return smCount; - } - - /// - /// [PRIVATE] - /// Gets the SP count for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of SP units. - public static uint GetTotalSPCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var spCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return spCount; - } - - /// - /// [PRIVATE] - /// Gets the TPC count for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of TPC units. - public static uint GetTotalTPCCount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var tpcCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return tpcCount; - } - - /// - /// This function returns the OEM revision of the video BIOS associated with this GPU. - /// - /// GPU handle to get information about - /// OEM revision of the video BIOS - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static uint GetVBIOSOEMRevision(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var revision); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return revision; - } - - /// - /// This function returns the revision of the video BIOS associated with this GPU. - /// TCC_SUPPORTED - /// - /// GPU handle to get information about - /// Revision of the video BIOS - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found. - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static uint GetVBIOSRevision(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var revision); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return revision; - } - - /// - /// This function returns the full video BIOS version string in the form of xx.xx.xx.xx.yy where xx numbers come from - /// GetVbiosRevision() and yy comes from GetVbiosOEMRevision(). - /// - /// Physical GPU handle to get information about - /// Full video BIOS version string - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static string GetVBIOSVersionString(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, - out var version); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return version.Value; - } - - /// - /// This function returns the virtual size of frame buffer in KB. This includes the physical RAM plus any system RAM - /// that has been dedicated for use by the GPU. - /// - /// Physical GPU handle to get information about - /// Virtual size of frame buffer in KB - /// Status.InvalidArgument: display is not valid - /// Status.NvidiaDeviceNotFound: No NVIDIA GPU driving a display was found - /// Status.ExpectedPhysicalGPUHandle: gpuHandle was not a physical GPU handle. - public static int GetVirtualFrameBufferSize(PhysicalGPUHandle gpuHandle) - { - var status = DelegateFactory.GetDelegate()(gpuHandle, - out var bufferSize); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return (int) bufferSize; - } - - /// - /// [PRIVATE] - /// Gets the VPE count for the passed GPU handle. - /// - /// The handle of the GPU to retrieve this information from. - /// The number of VPE units. - public static uint GetVPECount(PhysicalGPUHandle gpuHandle) - { - var status = - DelegateFactory.GetDelegate()(gpuHandle, out var vpeCount); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return vpeCount; - } - - /// - /// Reads data from I2C bus - /// - /// The physical GPU to access I2C bus. - /// The information required for the operation. Will be filled with data after retrieval. - // ReSharper disable once InconsistentNaming - public static void I2CRead(PhysicalGPUHandle gpuHandle, ref TI2CInfo i2cInfo) - where TI2CInfo : struct, II2CInfo - { - var c = i2cInfo as II2CInfo; - I2CRead(gpuHandle, ref c); - i2cInfo = (TI2CInfo) c; - } - - /// - /// Reads data from I2C bus - /// - /// The physical GPU to access I2C bus. - /// The information required for the operation. Will be filled with data after retrieval. - // ReSharper disable once InconsistentNaming - public static void I2CRead(PhysicalGPUHandle gpuHandle, ref II2CInfo i2cInfo) - { - var type = i2cInfo.GetType(); - // ReSharper disable once InconsistentNaming - var i2cRead = DelegateFactory.GetDelegate(); - - if (!i2cRead.Accepts().Contains(type)) - { - throw new ArgumentOutOfRangeException(nameof(type)); - } - - // ReSharper disable once InconsistentNaming - using (var i2cInfoReference = ValueTypeReference.FromValueType(i2cInfo, type)) - { - var status = i2cRead(gpuHandle, i2cInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - i2cInfo = i2cInfoReference.ToValueType(type); - } - } - - /// - /// Writes data to I2C bus - /// - /// The physical GPU to access I2C bus. - /// The information required for the operation. - // ReSharper disable once InconsistentNaming - public static void I2CWrite(PhysicalGPUHandle gpuHandle, II2CInfo i2cInfo) - { - var type = i2cInfo.GetType(); - // ReSharper disable once InconsistentNaming - var i2cWrite = DelegateFactory.GetDelegate(); - - if (!i2cWrite.Accepts().Contains(type)) - { - throw new ArgumentOutOfRangeException(nameof(type)); - } - - // ReSharper disable once InconsistentNaming - using (var i2cInfoReference = ValueTypeReference.FromValueType(i2cInfo, type)) - { - var status = i2cWrite(gpuHandle, i2cInfoReference); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This function resets ECC memory error counters. - /// - /// A handle identifying the physical GPU for which ECC error information is to be cleared. - /// Reset the current ECC error counters. - /// Reset the aggregate ECC error counters. - public static void ResetECCErrorInfo( - PhysicalGPUHandle gpuHandle, - bool resetCurrent, - bool resetAggregated) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - (byte) (resetCurrent ? 1 : 0), - (byte) (resetAggregated ? 1 : 0) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This function updates the ECC memory configuration setting. - /// - /// A handle identifying the physical GPU for which to update the ECC configuration setting. - /// The new ECC configuration setting. - /// Request that the new setting take effect immediately. - public static void SetECCConfiguration( - PhysicalGPUHandle gpuHandle, - bool isEnable, - bool isEnableImmediately) - { - var status = DelegateFactory.GetDelegate()( - gpuHandle, - (byte) (isEnable ? 1 : 0), - (byte) (isEnableImmediately ? 1 : 0) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/ChipsetInfoFlag.cs b/app/NvAPIWrapper/Native/General/ChipsetInfoFlag.cs deleted file mode 100644 index a092177a..00000000 --- a/app/NvAPIWrapper/Native/General/ChipsetInfoFlag.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.General -{ - /// - /// Chipset information flags - obsolete - /// - [Flags] - public enum ChipsetInfoFlag - { - /// - /// No flags - /// - None = 0, - - /// - /// Hybrid chipset configuration - /// - Hybrid = 1 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Status.cs b/app/NvAPIWrapper/Native/General/Status.cs deleted file mode 100644 index 6a94e437..00000000 --- a/app/NvAPIWrapper/Native/General/Status.cs +++ /dev/null @@ -1,642 +0,0 @@ -namespace NvAPIWrapper.Native.General -{ - /// - /// NvAPI status codes - /// - public enum Status - { - /// - /// Success. Request is completed. - /// - Ok = 0, - - /// - /// Generic error - /// - Error = -1, - - /// - /// NVAPI support library cannot be loaded. - /// - LibraryNotFound = -2, - - /// - /// Not implemented in current driver installation - /// - NoImplementation = -3, - - /// - /// NvAPI_Initialize() has not been called (successfully) - /// - ApiNotInitialized = -4, - - /// - /// Invalid argument - /// - InvalidArgument = -5, - - /// - /// No NVIDIA display driver was found - /// - NvidiaDeviceNotFound = -6, - - /// - /// No more to enumerate - /// - EndEnumeration = -7, - - /// - /// Invalid handle - /// - InvalidHandle = -8, - - /// - /// An argument's structure version is not supported - /// - IncompatibleStructureVersion = -9, - - /// - /// Handle is no longer valid (likely due to GPU or display re-configuration) - /// - HandleInvalidated = -10, - - /// - /// No NVIDIA OpenGL context is current (but needs to be) - /// - OpenGLContextNotCurrent = -11, - - /// - /// An invalid pointer, usually NULL, was passed as a parameter - /// - InvalidPointer = -14, - - /// - /// OpenGL Expert is not supported by the current drivers - /// - NoGLExpert = -12, - - /// - /// OpenGL Expert is supported, but driver instrumentation is currently disabled - /// - InstrumentationDisabled = -13, - - /// - /// Expected a logical GPU handle for one or more parameters - /// - ExpectedLogicalGPUHandle = -100, - - /// - /// Expected a physical GPU handle for one or more parameters - /// - ExpectedPhysicalGPUHandle = -101, - - /// - /// Expected an NV display handle for one or more parameters - /// - ExpectedDisplayHandle = -102, - - /// - /// Used in some commands to indicate that the combination of parameters is not valid - /// - InvalidCombination = -103, - - /// - /// Requested feature not supported in the selected GPU - /// - NotSupported = -104, - - /// - /// NO port Id found for I2C transaction - /// - PortIdNotFound = -105, - - /// - /// Expected an unattached display handle as one of the input param - /// - ExpectedUnattachedDisplayHandle = -106, - - /// - /// Invalid performance level - /// - InvalidPerformanceLevel = -107, - - /// - /// Device is busy, request not fulfilled - /// - DeviceBusy = -108, - - /// - /// NVIDIA persist file is not found - /// - NvPersistFileNotFound = -109, - - /// - /// NVIDIA persist data is not found - /// - PersistDataNotFound = -110, - - /// - /// Expected TV output display - /// - ExpectedTVDisplay = -111, - - /// - /// Expected TV output on D Connector - HDTV_EIAJ4120. - /// - ExpectedTVDisplayOnDConnector = -112, - - /// - /// SLI is not active on this device - /// - NoActiveSLITopology = -113, - - /// - /// Setup of SLI rendering mode is not possible right now - /// - SLIRenderingModeNotAllowed = -114, - - /// - /// Expected digital flat panel - /// - ExpectedDigitalFlatPanel = -115, - - /// - /// Argument exceeds expected size - /// - ArgumentExceedMaxSize = -116, - - /// - /// Inhibit ON due to one of the flags in NV_GPU_DISPLAY_CHANGE_INHIBIT or SLI Active - /// - DeviceSwitchingNotAllowed = -117, - - /// - /// Testing clocks not supported - /// - TestingClocksNotSupported = -118, - - /// - /// The specified underscan config is from an unknown source (e.g. INF) - /// - UnknownUnderScanConfig = -119, - - /// - /// Timeout while reconfiguring GPUs - /// - TimeoutReConfiguringGPUTopology = -120, - - /// - /// Requested data was not found - /// - DataNotFound = -121, - - /// - /// Expected analog display - /// - ExpectedAnalogDisplay = -122, - - /// - /// No SLI video bridge present - /// - NoVideoLink = -123, - - /// - /// NvAPI requires reboot for its settings to take effect - /// - RequiresReboot = -124, - - /// - /// The function is not supported with the current hybrid mode. - /// - InvalidHybridMode = -125, - - /// - /// The target types are not all the same - /// - MixedTargetTypes = -126, - - /// - /// The function is not supported from 32-bit on a 64-bit system - /// - SYSWOW64NotSupported = -127, - - /// - /// There is any implicit GPU topology active. Use NVAPI_SetHybridMode to change topology. - /// - ImplicitSetGPUTopologyChangeNotAllowed = -128, - - - /// - /// Prompt the user to close all non-migratable applications. - /// - RequestUserToCloseNonMigratableApps = -129, - - /// - /// Could not allocate sufficient memory to complete the call - /// - OutOfMemory = -130, - - /// - /// The previous operation that is transferring information to or from this surface is incomplete - /// - WasStillDrawing = -131, - - /// - /// The file was not found - /// - FileNotFound = -132, - - /// - /// There are too many unique instances of a particular type of state object - /// - TooManyUniqueStateObjects = -133, - - - /// - /// The method call is invalid. For example, a method's parameter may not be a valid pointer - /// - InvalidCall = -134, - - /// - /// d3d10_1.dll can not be loaded - /// - D3D101LibraryNotFound = -135, - - /// - /// Couldn't find the function in loaded DLL library - /// - FunctionNotFound = -136, - - /// - /// Current User is not Administrator - /// - InvalidUserPrivilege = -137, - - /// - /// The handle corresponds to GDIPrimary - /// - ExpectedNonPrimaryDisplayHandle = -138, - - /// - /// Setting PhysX GPU requires that the GPU is compute capable - /// - ExpectedComputeGPUHandle = -139, - - /// - /// Stereo part of NvAPI failed to initialize completely. Check if stereo driver is installed. - /// - StereoNotInitialized = -140, - - /// - /// Access to stereo related registry keys or values failed. - /// - StereoRegistryAccessFailed = -141, - - /// - /// Given registry profile type is not supported. - /// - StereoRegistryProfileTypeNotSupported = -142, - - /// - /// Given registry value is not supported. - /// - StereoRegistryValueNotSupported = -143, - - /// - /// Stereo is not enabled and function needed it to execute completely. - /// - StereoNotEnabled = -144, - - /// - /// Stereo is not turned on and function needed it to execute completely. - /// - StereoNotTurnedOn = -145, - - /// - /// Invalid device interface. - /// - StereoInvalidDeviceInterface = -146, - - - /// - /// Separation percentage or JPEG image capture quality out of [0-100] range. - /// - StereoParameterOutOfRange = -147, - - /// - /// Given frustum adjust mode is not supported. - /// - StereoFrustumAdjustModeNotSupported = -148, - - /// - /// The mosaic topology is not possible given the current state of HW - /// - TopologyNotPossible = -149, - - /// - /// An attempt to do a display resolution mode change has failed - /// - ModeChangeFailed = -150, - - /// - /// d3d11.dll/d3d11_beta.dll cannot be loaded. - /// - D3D11LibraryNotFound = -151, - - /// - /// Address outside of valid range. - /// - InvalidAddress = -152, - - /// - /// The pre-allocated string is too small to hold the result. - /// - StringTooSmall = -153, - - /// - /// The input does not match any of the available devices. - /// - MatchingDeviceNotFound = -154, - - /// - /// Driver is running. - /// - DriverRunning = -155, - - /// - /// Driver is not running. - /// - DriverNotRunning = -156, - - /// - /// A driver reload is required to apply these settings. - /// - ErrorDriverReloadRequired = -157, - - /// - /// Intended setting is not allowed. - /// - SetNotAllowed = -158, - - /// - /// Information can't be returned due to "advanced display topology". - /// - AdvancedDisplayTopologyRequired = -159, - - /// - /// Setting is not found. - /// - SettingNotFound = -160, - - /// - /// Setting size is too large. - /// - SettingSizeTooLarge = -161, - - /// - /// There are too many settings for a profile. - /// - TooManySettingsInProfile = -162, - - /// - /// Profile is not found. - /// - ProfileNotFound = -163, - - /// - /// Profile name is duplicated. - /// - ProfileNameInUse = -164, - - /// - /// Profile name is empty. - /// - ProfileNameEmpty = -165, - - /// - /// Application not found in the Profile. - /// - ExecutableNotFound = -166, - - /// - /// Application already exists in the other profile. - /// - ExecutableAlreadyInUse = -167, - - /// - /// Data Type mismatch - /// - DataTypeMismatch = -168, - - /// - /// The profile passed as parameter has been removed and is no longer valid. - /// - ProfileRemoved = -169, - - /// - /// An unregistered resource was passed as a parameter. - /// - UnregisteredResource = -170, - - /// - /// The DisplayId corresponds to a display which is not within the normal outputId range. - /// - IdOutOfRange = -171, - - /// - /// Display topology is not valid so the driver cannot do a mode set on this configuration. - /// - DisplayConfigValidationFailed = -172, - - /// - /// Display Port Multi-Stream topology has been changed. - /// - DPMSTChanged = -173, - - /// - /// Input buffer is insufficient to hold the contents. - /// - InsufficientBuffer = -174, - - /// - /// No access to the caller. - /// - AccessDenied = -175, - - /// - /// The requested action cannot be performed without Mosaic being enabled. - /// - MosaicNotActive = -176, - - /// - /// The surface is relocated away from video memory. - /// - ShareResourceRelocated = -177, - - /// - /// The user should disable DWM before calling NvAPI. - /// - RequestUserToDisableDWM = -178, - - /// - /// D3D device status is "D3DERR_DEVICELOST" or "D3DERR_DEVICENOTRESET" - the user has to reset the device. - /// - D3DDeviceLost = -179, - - /// - /// The requested action cannot be performed in the current state. - /// - InvalidConfiguration = -180, - - /// - /// Call failed as stereo handshake not completed. - /// - StereoHandshakeNotDone = -181, - - /// - /// The path provided was too short to determine the correct NVDRS_APPLICATION - /// - ExecutablePathIsAmbiguous = -182, - - /// - /// Default stereo profile is not currently defined - /// - DefaultStereoProfileIsNotDefined = -183, - - /// - /// Default stereo profile does not exist - /// - DefaultStereoProfileDoesNotExist = -184, - - /// - /// A cluster is already defined with the given configuration. - /// - ClusterAlreadyExists = -185, - - /// - /// The input display id is not that of a multi stream enabled connector or a display device in a multi stream topology - /// - DPMSTDisplayIdExpected = -186, - - /// - /// The input display id is not valid or the monitor associated to it does not support the current operation - /// - InvalidDisplayId = -187, - - /// - /// While playing secure audio stream, stream goes out of sync - /// - StreamIsOutOfSync = -188, - - /// - /// Older audio driver version than required - /// - IncompatibleAudioDriver = -189, - - /// - /// Value already set, setting again not allowed. - /// - ValueAlreadySet = -190, - - /// - /// Requested operation timed out - /// - Timeout = -191, - - /// - /// The requested workstation feature set has incomplete driver internal allocation resources - /// - GPUWorkstationFeatureIncomplete = -192, - - /// - /// Call failed because InitActivation was not called. - /// - StereoInitActivationNotDone = -193, - - /// - /// The requested action cannot be performed without Sync being enabled. - /// - SyncNotActive = -194, - - /// - /// The requested action cannot be performed without Sync Master being enabled. - /// - SyncMasterNotFound = -195, - - /// - /// Invalid displays passed in the NV_GSYNC_DISPLAY pointer. - /// - InvalidSyncTopology = -196, - - /// - /// The specified signing algorithm is not supported. Either an incorrect value was entered or the current installed - /// driver/hardware does not support the input value. - /// - ECIDSignAlgoUnsupported = -197, - - /// - /// The encrypted public key verification has failed. - /// - ECIDKeyVerificationFailed = -198, - - /// - /// The device's firmware is out of date. - /// - FirmwareOutOfDate = -199, - - /// - /// The device's firmware is not supported. - /// - FirmwareRevisionNotSupported = -200, - - /// - /// The caller is not authorized to modify the License. - /// - LicenseCallerAuthenticationFailed = -201, - - /// - /// The user tried to use a deferred context without registering the device first - /// - D3DDeviceNotRegistered = -202, - - /// - /// Head or SourceId was not reserved for the VR Display before doing the Mode-Set. - /// - ResourceNotAcquired = -203, - - /// - /// Provided timing is not supported. - /// - TimingNotSupported = -204, - - /// - /// HDCP Encryption Failed for the device. Would be applicable when the device is HDCP Capable. - /// - HDCPEncryptionFailed = -205, - - /// - /// Provided mode is over sink device pclk limitation. - /// - PCLKLimitationFailed = -206, - - /// - /// No connector on GPU found. - /// - NoConnectorFound = -207, - - /// - /// When a non-HDCP capable HMD is connected, we would inform user by this code. - /// - HDCPDisabled = -208, - - /// - /// At least an API is still being called - /// - ApiInUse = -209, - - /// - /// No display found on Nvidia GPU(s). - /// - NVIDIADisplayNotFound = -210 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV1.cs b/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV1.cs deleted file mode 100644 index 3420a59c..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV1.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Holds information about the system's chipset. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct ChipsetInfoV1 : IInitializable, IChipsetInfo, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _VendorId; - internal readonly uint _DeviceId; - internal readonly ShortString _VendorName; - internal readonly ShortString _ChipsetName; - - /// - public bool Equals(ChipsetInfoV1 other) - { - return _VendorId == other._VendorId && - _DeviceId == other._DeviceId && - _VendorName.Equals(other._VendorName) && - _ChipsetName.Equals(other._ChipsetName); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ChipsetInfoV1 v1 && Equals(v1); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _VendorId; - hashCode = (hashCode * 397) ^ (int) _DeviceId; - hashCode = (hashCode * 397) ^ _VendorName.GetHashCode(); - hashCode = (hashCode * 397) ^ _ChipsetName.GetHashCode(); - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"{VendorName} {ChipsetName}"; - } - - /// - public int VendorId - { - get => (int) _VendorId; - } - - /// - public int DeviceId - { - get => (int) _DeviceId; - } - - /// - public string VendorName - { - get => _VendorName.Value; - } - - /// - public string ChipsetName - { - get => _ChipsetName.Value; - } - - /// - public ChipsetInfoFlag Flags - { - get => ChipsetInfoFlag.None; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV2.cs b/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV2.cs deleted file mode 100644 index 3abb1e0f..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV2.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Holds information about the system's chipset. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct ChipsetInfoV2 : IInitializable, IChipsetInfo, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _VendorId; - internal readonly uint _DeviceId; - internal readonly ShortString _VendorName; - internal readonly ShortString _ChipsetName; - internal readonly ChipsetInfoFlag _Flags; - - /// - public bool Equals(ChipsetInfoV2 other) - { - return _VendorId == other._VendorId && - _DeviceId == other._DeviceId && - _VendorName.Equals(other._VendorName) && - _ChipsetName.Equals(other._ChipsetName) && - _Flags == other._Flags; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ChipsetInfoV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _VendorId; - hashCode = (hashCode * 397) ^ (int) _DeviceId; - hashCode = (hashCode * 397) ^ _VendorName.GetHashCode(); - hashCode = (hashCode * 397) ^ _ChipsetName.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _Flags; - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"{VendorName} {ChipsetName}"; - } - - /// - public int VendorId - { - get => (int) _VendorId; - } - - /// - public int DeviceId - { - get => (int) _DeviceId; - } - - /// - public string VendorName - { - get => _VendorName.Value; - } - - /// - public string ChipsetName - { - get => _ChipsetName.Value; - } - - /// - public ChipsetInfoFlag Flags - { - get => _Flags; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV3.cs b/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV3.cs deleted file mode 100644 index e05f3868..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV3.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Holds information about the system's chipset. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(3)] - public struct ChipsetInfoV3 : IInitializable, IChipsetInfo, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _VendorId; - internal readonly uint _DeviceId; - internal readonly ShortString _VendorName; - internal readonly ShortString _ChipsetName; - internal readonly ChipsetInfoFlag _Flags; - internal readonly uint _SubSystemVendorId; - internal readonly uint _SubSystemDeviceId; - internal readonly ShortString _SubSystemVendorName; - - /// - public bool Equals(ChipsetInfoV3 other) - { - return _VendorId == other._VendorId && - _DeviceId == other._DeviceId && - _VendorName.Equals(other._VendorName) && - _ChipsetName.Equals(other._ChipsetName) && - _Flags == other._Flags && - _SubSystemVendorId == other._SubSystemVendorId && - _SubSystemDeviceId == other._SubSystemDeviceId && - _SubSystemVendorName.Equals(other._SubSystemVendorName); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ChipsetInfoV3 v3 && Equals(v3); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _VendorId; - hashCode = (hashCode * 397) ^ (int) _DeviceId; - hashCode = (hashCode * 397) ^ _VendorName.GetHashCode(); - hashCode = (hashCode * 397) ^ _ChipsetName.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _Flags; - hashCode = (hashCode * 397) ^ (int) _SubSystemVendorId; - hashCode = (hashCode * 397) ^ (int) _SubSystemDeviceId; - hashCode = (hashCode * 397) ^ _SubSystemVendorName.GetHashCode(); - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"{SubSystemVendorName} {VendorName} {ChipsetName}"; - } - - /// - public int VendorId - { - get => (int) _VendorId; - } - - /// - public int DeviceId - { - get => (int) _DeviceId; - } - - /// - public string VendorName - { - get => _VendorName.Value; - } - - /// - public string ChipsetName - { - get => _ChipsetName.Value; - } - - /// - public ChipsetInfoFlag Flags - { - get => _Flags; - } - - /// - /// Chipset subsystem vendor identification - /// - public int SubSystemVendorId - { - get => (int) _SubSystemVendorId; - } - - /// - /// Chipset subsystem device identification - /// - public int SubSystemDeviceId - { - get => (int) _SubSystemDeviceId; - } - - /// - /// Chipset subsystem vendor name - /// - public string SubSystemVendorName - { - get => _SubSystemVendorName.Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV4.cs b/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV4.cs deleted file mode 100644 index 00bdf303..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/ChipsetInfoV4.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Holds information about the system's chipset. - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(4)] - public struct ChipsetInfoV4 : IInitializable, IChipsetInfo, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _VendorId; - internal readonly uint _DeviceId; - internal readonly ShortString _VendorName; - internal readonly ShortString _ChipsetName; - internal readonly ChipsetInfoFlag _Flags; - internal readonly uint _SubSystemVendorId; - internal readonly uint _SubSystemDeviceId; - internal readonly ShortString _SubSystemVendorName; - internal readonly uint _HostBridgeVendorId; - internal readonly uint _HostBridgeDeviceId; - internal readonly uint _HostBridgeSubSystemVendorId; - internal readonly uint _HostBridgeSubSystemDeviceId; - - /// - public bool Equals(ChipsetInfoV4 other) - { - return _VendorId == other._VendorId && - _DeviceId == other._DeviceId && - _VendorName.Equals(other._VendorName) && - _ChipsetName.Equals(other._ChipsetName) && - _Flags == other._Flags && - _SubSystemVendorId == other._SubSystemVendorId && - _SubSystemDeviceId == other._SubSystemDeviceId && - _SubSystemVendorName.Equals(other._SubSystemVendorName) && - _HostBridgeVendorId == other._HostBridgeVendorId && - _HostBridgeDeviceId == other._HostBridgeDeviceId && - _HostBridgeSubSystemVendorId == other._HostBridgeSubSystemVendorId && - _HostBridgeSubSystemDeviceId == other._HostBridgeSubSystemDeviceId; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ChipsetInfoV4 v4 && Equals(v4); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _VendorId; - hashCode = (hashCode * 397) ^ (int) _DeviceId; - hashCode = (hashCode * 397) ^ _VendorName.GetHashCode(); - hashCode = (hashCode * 397) ^ _ChipsetName.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _Flags; - hashCode = (hashCode * 397) ^ (int) _SubSystemVendorId; - hashCode = (hashCode * 397) ^ (int) _SubSystemDeviceId; - hashCode = (hashCode * 397) ^ _SubSystemVendorName.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _HostBridgeVendorId; - hashCode = (hashCode * 397) ^ (int) _HostBridgeDeviceId; - hashCode = (hashCode * 397) ^ (int) _HostBridgeSubSystemVendorId; - hashCode = (hashCode * 397) ^ (int) _HostBridgeSubSystemDeviceId; - - return hashCode; - } - } - - /// - public override string ToString() - { - return $"{SubSystemVendorName} {VendorName} {ChipsetName}"; - } - - /// - public int VendorId - { - get => (int) _VendorId; - } - - /// - public int DeviceId - { - get => (int) _DeviceId; - } - - /// - public string VendorName - { - get => _VendorName.Value; - } - - /// - public string ChipsetName - { - get => _ChipsetName.Value; - } - - /// - public ChipsetInfoFlag Flags - { - get => _Flags; - } - - /// - /// Chipset subsystem vendor identification - /// - public int SubSystemVendorId - { - get => (int) _SubSystemVendorId; - } - - /// - /// Chipset subsystem device identification - /// - public int SubSystemDeviceId - { - get => (int) _SubSystemDeviceId; - } - - /// - /// Chipset subsystem vendor name - /// - public string SubSystemVendorName - { - get => _SubSystemVendorName.Value; - } - - /// - /// Host bridge vendor identification - /// - public int HostBridgeVendorId - { - get => (int) _HostBridgeVendorId; - } - - /// - /// Host bridge device identification - /// - public int HostBridgeDeviceId - { - get => (int) _HostBridgeDeviceId; - } - - /// - /// Host bridge subsystem vendor identification - /// - public int HostBridgeSubSystemVendorId - { - get => (int) _HostBridgeSubSystemVendorId; - } - - /// - /// Host bridge subsystem device identification - /// - public int HostBridgeSubSystemDeviceId - { - get => (int) _HostBridgeSubSystemDeviceId; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/GenericString.cs b/app/NvAPIWrapper/Native/General/Structures/GenericString.cs deleted file mode 100644 index ad6dfe0a..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/GenericString.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.General.Structures -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct GenericString : IInitializable - { - public const int GenericStringLength = 4096; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = GenericStringLength)] - private readonly string _Value; - - public string Value - { - get => _Value; - } - - public GenericString(string value) - { - _Value = value ?? string.Empty; - } - - public override string ToString() - { - return Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/LIDDockParameters.cs b/app/NvAPIWrapper/Native/General/Structures/LIDDockParameters.cs deleted file mode 100644 index 02b5ae54..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/LIDDockParameters.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Holds information about the lid and dock - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct LidDockParameters : IInitializable, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _CurrentLIDState; - internal readonly uint _CurrentDockState; - internal readonly uint _CurrentLIDPolicy; - internal readonly uint _CurrentDockPolicy; - internal readonly uint _ForcedLIDMechanismPresent; - internal readonly uint _ForcedDockMechanismPresent; - - /// - public bool Equals(LidDockParameters other) - { - return _CurrentLIDState == other._CurrentLIDState && - _CurrentDockState == other._CurrentDockState && - _CurrentLIDPolicy == other._CurrentLIDPolicy && - _CurrentDockPolicy == other._CurrentDockPolicy && - _ForcedLIDMechanismPresent == other._ForcedLIDMechanismPresent && - _ForcedDockMechanismPresent == other._ForcedDockMechanismPresent; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is LidDockParameters parameters && Equals(parameters); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _CurrentLIDState; - hashCode = (hashCode * 397) ^ (int) _CurrentDockState; - hashCode = (hashCode * 397) ^ (int) _CurrentLIDPolicy; - hashCode = (hashCode * 397) ^ (int) _CurrentDockPolicy; - hashCode = (hashCode * 397) ^ (int) _ForcedLIDMechanismPresent; - hashCode = (hashCode * 397) ^ (int) _ForcedDockMechanismPresent; - - return hashCode; - } - } - - /// - /// Gets current lid state - /// - public uint CurrentLidState - { - get => _CurrentLIDState; - } - - /// - /// Gets current dock state - /// - public uint CurrentDockState - { - get => _CurrentDockState; - } - - /// - /// Gets current lid policy - /// - public uint CurrentLidPolicy - { - get => _CurrentLIDPolicy; - } - - /// - /// Gets current dock policy - /// - public uint CurrentDockPolicy - { - get => _CurrentDockPolicy; - } - - /// - /// Gets forced lid mechanism present - /// - public uint ForcedLidMechanismPresent - { - get => _ForcedLIDMechanismPresent; - } - - /// - /// Gets forced dock mechanism present - /// - public uint ForcedDockMechanismPresent - { - get => _ForcedDockMechanismPresent; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/LongString.cs b/app/NvAPIWrapper/Native/General/Structures/LongString.cs deleted file mode 100644 index 97170208..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/LongString.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.General.Structures -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct LongString : IInitializable - { - public const int LongStringLength = 256; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = LongStringLength)] - private readonly string _Value; - - public string Value - { - get => _Value; - } - - public LongString(string value) - { - _Value = value ?? string.Empty; - } - - public override string ToString() - { - return Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/Rectangle.cs b/app/NvAPIWrapper/Native/General/Structures/Rectangle.cs deleted file mode 100644 index 1a0c7a8e..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/Rectangle.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.General.Structures -{ - /// - /// Represents a rectangle coordinates - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct Rectangle - { - internal int _X; - internal int _Y; - internal int _Width; - internal int _Height; - - /// - /// Creates a new instance of - /// - /// The horizontal location value. - /// The vertical location value. - /// The width of the rectangle. - /// The height of the rectangle. - // ReSharper disable once TooManyDependencies - public Rectangle(int x, int y, int width, int height) - { - _X = x; - _Y = y; - _Width = width; - _Height = height; - } - - /// - /// Gets the horizontal location value - /// - public int X - { - get => _X; - } - - /// - /// Gets the vertical location value - /// - public int Y - { - get => _Y; - } - - /// - /// Gets the rectangle width value - /// - public int Width - { - get => _Width; - } - - /// - /// Gets the rectangle height value - /// - public int Height - { - get => _Height; - } - - /// - /// Gets the horizontal left edge value - /// - public int X2 - { - get => X + Width; - } - - /// - /// Gets the vertical bottom edge value - /// - public int Y2 - { - get => Y + Height; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/ShortString.cs b/app/NvAPIWrapper/Native/General/Structures/ShortString.cs deleted file mode 100644 index 3385b332..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/ShortString.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.General.Structures -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - internal struct ShortString : IInitializable - { - public const int ShortStringLength = 64; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = ShortStringLength)] - private readonly string _Value; - - public string Value - { - get => _Value; - } - - public ShortString(string value) - { - _Value = value ?? string.Empty; - } - - public override string ToString() - { - return Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/StructureVersion.cs b/app/NvAPIWrapper/Native/General/Structures/StructureVersion.cs deleted file mode 100644 index e18f8f7f..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/StructureVersion.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace NvAPIWrapper.Native.General.Structures -{ - [StructLayout(LayoutKind.Sequential)] - internal struct StructureVersion - { - private readonly uint _version; - - public int VersionNumber - { - get => (int) (_version >> 16); - } - - public int StructureSize - { - get => (int) (_version & ~(0xFFFF << 16)); - } - - public StructureVersion(int version, Type structureType) - { - _version = (uint) (Marshal.SizeOf(structureType) | (version << 16)); - } - - public override string ToString() - { - return $"Structure Size: {StructureSize} Bytes, Version: {VersionNumber}"; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/General/Structures/UnicodeString.cs b/app/NvAPIWrapper/Native/General/Structures/UnicodeString.cs deleted file mode 100644 index 5ba67b1b..00000000 --- a/app/NvAPIWrapper/Native/General/Structures/UnicodeString.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.General.Structures -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct UnicodeString : IInitializable - { - public const int UnicodeStringLength = 2048; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = UnicodeStringLength)] - private readonly string _Value; - - public string Value - { - get => _Value; - } - - public UnicodeString(string value) - { - _Value = value ?? string.Empty; - } - - public override string ToString() - { - return Value; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/GeneralApi.cs b/app/NvAPIWrapper/Native/GeneralApi.cs deleted file mode 100644 index 4d315331..00000000 --- a/app/NvAPIWrapper/Native/GeneralApi.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.General; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains system and general static functions - /// - public static class GeneralApi - { - /// - /// This function returns information about the system's chipset. - /// - /// Information about the system's chipset - /// This operation is not supported. - /// Status.InvalidArgument: Invalid argument - /// A delegate callback throws an exception. - public static IChipsetInfo GetChipsetInfo() - { - var getChipSetInfo = DelegateFactory.GetDelegate(); - - foreach (var acceptType in getChipSetInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var chipsetInfoReference = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = getChipSetInfo(chipsetInfoReference); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return chipsetInfoReference.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - - /// - /// This API returns display driver version and driver-branch string. - /// - /// Contains the driver-branch string after successful return. - /// Returns driver version - /// Status.ApiNotInitialized: NVAPI not initialized - /// Status.Error: Miscellaneous error occurred - public static uint GetDriverAndBranchVersion(out string branchVersion) - { - var status = DelegateFactory.GetDelegate()( - out var driverVersion, out var branchVersionShortString); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - branchVersion = branchVersionShortString.Value; - - return driverVersion; - } - - /// - /// This function converts an NvAPI error code into a null terminated string. - /// - /// The error code to convert - /// The string corresponding to the error code - // ReSharper disable once FlagArgument - public static string GetErrorMessage(Status statusCode) - { - statusCode = - DelegateFactory.GetDelegate()(statusCode, out var message); - - if (statusCode != Status.Ok) - { - return null; - } - - return message.Value; - } - - /// - /// This function returns a string describing the version of the NvAPI library. The contents of the string are human - /// readable. Do not assume a fixed format. - /// - /// User readable string giving NvAPI version information - /// See NVIDIAApiException.Status for the reason of the exception. - public static string GetInterfaceVersionString() - { - var status = - DelegateFactory.GetDelegate()(out var version); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return version.Value; - } - - /// - /// This function returns the current lid and dock information. - /// - /// Current lid and dock information - /// Status.Error: Generic error - /// Status.NotSupported: Requested feature not supported - /// Status.HandleInvalidated: Handle is no longer valid - /// Status.ApiNotInitialized: NvAPI_Initialize() has not been called - public static LidDockParameters GetLidAndDockInfo() - { - var dockInfo = typeof(LidDockParameters).Instantiate(); - var status = DelegateFactory.GetDelegate()(ref dockInfo); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return dockInfo; - } - - /// - /// This function initializes the NvAPI library (if not already initialized) but always increments the ref-counter. - /// This must be called before calling other NvAPI_ functions. - /// - /// Status.Error: Generic error - /// Status.LibraryNotFound: nvapi.dll can not be loaded - public static void Initialize() - { - var status = DelegateFactory.GetDelegate()(); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// PRIVATE - Requests to restart the display driver - /// - public static void RestartDisplayDriver() - { - var status = DelegateFactory.GetDelegate()(); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// Decrements the ref-counter and when it reaches ZERO, unloads NVAPI library. - /// This must be called in pairs with NvAPI_Initialize. - /// Note: By design, it is not mandatory to call NvAPI_Initialize before calling any NvAPI. - /// When any NvAPI is called without first calling NvAPI_Initialize, the internal ref-counter will be implicitly - /// incremented. In such cases, calling NvAPI_Initialize from a different thread will result in incrementing the - /// ref-count again and the user has to call NvAPI_Unload twice to unload the library. However, note that the implicit - /// increment of the ref-counter happens only once. - /// If the client wants unload functionality, it is recommended to always call NvAPI_Initialize and NvAPI_Unload in - /// pairs. - /// Unloading NvAPI library is not supported when the library is in a resource locked state. - /// Some functions in the NvAPI library initiates an operation or allocates certain resources and there are - /// corresponding functions available, to complete the operation or free the allocated resources. All such function - /// pairs are designed to prevent unloading NvAPI library. - /// For example, if NvAPI_Unload is called after NvAPI_XXX which locks a resource, it fails with NVAPI_ERROR. - /// Developers need to call the corresponding NvAPI_YYY to unlock the resources, before calling NvAPI_Unload again. - /// - /// Status.Error: Generic error - /// - /// Status.ApiInUse: At least an API is still being called hence cannot unload NVAPI - /// library from process - /// - public static void Unload() - { - var status = DelegateFactory.GetDelegate()(); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/DelegateFactory.cs b/app/NvAPIWrapper/Native/Helpers/DelegateFactory.cs deleted file mode 100644 index 662692e8..00000000 --- a/app/NvAPIWrapper/Native/Helpers/DelegateFactory.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Exceptions; - -namespace NvAPIWrapper.Native.Helpers -{ - internal static class DelegateFactory - { - private static readonly Dictionary, object> Delegates = - new Dictionary, object>(); - - public static T GetDelegate() where T : class - { - if (!typeof(T).IsSubclassOf(typeof(Delegate))) - { - throw new InvalidOperationException($"{typeof(T).Name} is not a delegate type"); - } - - var functionId = typeof(T).GetCustomAttributes(typeof(FunctionIdAttribute), true) - .Cast() - .FirstOrDefault(); - - if (functionId == null) - { - throw new InvalidOperationException($"{typeof(T).Name}'s address is unknown."); - } - - var delegateKey = new KeyValuePair(functionId.FunctionId, typeof(T)); - - lock (Delegates) - { - if (Delegates.ContainsKey(delegateKey)) - { - return Delegates[delegateKey] as T; - } - - var ptr = NvAPI_QueryInterface((uint) functionId.FunctionId); - - if (ptr != IntPtr.Zero) - { - var delegateValue = Marshal.GetDelegateForFunctionPointer(ptr, typeof(T)) as T; - Delegates.Add(delegateKey, delegateValue); - - return delegateValue; - } - } - - throw new NVIDIANotSupportedException(@"Function identification number is invalid or not supported."); - } - - private static IntPtr NvAPI_QueryInterface(uint interfaceId) - { - if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess) - { - throw new NVIDIANotSupportedException( - "32bit process running in a 64bit environment can't access NVIDIA API."); - } - - return Environment.Is64BitProcess - ? NvAPI64_QueryInterface(interfaceId) - : NvAPI32_QueryInterface(interfaceId); - } - - [DllImport(@"nvapi", EntryPoint = @"nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl, - PreserveSig = true)] - private static extern IntPtr NvAPI32_QueryInterface(uint interfaceId); - - [DllImport(@"nvapi64", EntryPoint = @"nvapi_QueryInterface", CallingConvention = CallingConvention.Cdecl, - PreserveSig = true)] - private static extern IntPtr NvAPI64_QueryInterface(uint interfaceId); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/ExtensionMethods.cs b/app/NvAPIWrapper/Native/Helpers/ExtensionMethods.cs deleted file mode 100644 index f9727d87..00000000 --- a/app/NvAPIWrapper/Native/Helpers/ExtensionMethods.cs +++ /dev/null @@ -1,291 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Helpers -{ - internal static class ExtensionMethods - { - /// A delegate callback throws an exception. - public static Type[] Accepts(this Delegate @delegate, int parameterIndex = 0) - { - Type[] types = null; - var parameters = @delegate.GetType().GetMethod("Invoke")?.GetParameters(); - - if (parameterIndex > 0) - { - if (parameters?.Length >= parameterIndex) - { - types = parameters[parameterIndex - 1].GetCustomAttributes(typeof(AcceptsAttribute), true) - .Cast() - .FirstOrDefault()? - .Types; - } - } - - if (types == null) - { - if (parameters != null) - { - types = parameters.SelectMany(param => param.GetCustomAttributes(typeof(AcceptsAttribute), true)) - .Cast() - .FirstOrDefault()? - .Types; - } - else - { - types = @delegate.GetType().GetCustomAttributes(typeof(AcceptsAttribute), false) - .Cast() - .FirstOrDefault()? - .Types; - } - } - - return types ?? new Type[0]; - } - - public static IEnumerable AllocateAll(this IEnumerable allocatableArray) - { - foreach ( - var allocatable in - allocatableArray.Where(item => item.GetType().GetInterfaces().Contains(typeof(IAllocatable)))) - { - var boxedCopy = (IAllocatable) allocatable; - boxedCopy.Allocate(); - - yield return (T) boxedCopy; - } - } - - public static TResult BitWiseConvert(T source) - where TResult : struct, IConvertible - where T : struct, IConvertible - { - if (typeof(T) == typeof(TResult)) - { - return (TResult) (object) source; - } - - var sourceSize = Marshal.SizeOf(typeof(T)); - var destinationSize = Marshal.SizeOf(typeof(TResult)); - var minSize = Math.Min(sourceSize, destinationSize); - var sourcePointer = Marshal.AllocHGlobal(sourceSize); - Marshal.StructureToPtr(source, sourcePointer, false); - var bytes = new byte[destinationSize]; - - if (BitConverter.IsLittleEndian) - { - Marshal.Copy(sourcePointer, bytes, 0, minSize); - } - else - { - Marshal.Copy(sourcePointer + (sourceSize - minSize), bytes, destinationSize - minSize, minSize); - } - - Marshal.FreeHGlobal(sourcePointer); - var destinationPointer = Marshal.AllocHGlobal(destinationSize); - Marshal.Copy(bytes, 0, destinationPointer, destinationSize); - var destination = (TResult) Marshal.PtrToStructure(destinationPointer, typeof(TResult)); - Marshal.FreeHGlobal(destinationPointer); - - return destination; - } - - public static void DisposeAll(this IEnumerable disposableArray) - { - foreach ( - var disposable in - disposableArray.Where( - item => - item.GetType() - .GetInterfaces() - .Any(i => i == typeof(IDisposable) || i == typeof(IAllocatable)))) - { - ((IDisposable) disposable).Dispose(); - } - } - - public static bool GetBit(this T integer, int index) where T : struct, IConvertible - { - var bigInteger = BitWiseConvert(integer); - var mask = 1ul << index; - - return (bigInteger & mask) > 0; - } - - public static ulong GetBits(this T integer, int index, int count) where T : struct, IConvertible - { - var bigInteger = BitWiseConvert(integer); - - if (index > 0) - { - bigInteger >>= index; - } - - count = 64 - count; - bigInteger <<= count; - bigInteger >>= count; - - return bigInteger; - } - - - // ReSharper disable once FunctionComplexityOverflow - // ReSharper disable once ExcessiveIndentation - public static T Instantiate(this Type type) - { - object instance = default(T); - - try - { - if (type.IsValueType) - { - instance = (T) Activator.CreateInstance(type); - } - - if (type.GetInterfaces().Any(i => i == typeof(IInitializable) || i == typeof(IAllocatable))) - { - foreach (var field in type.GetRuntimeFields()) - { - if (field.IsStatic || field.IsLiteral) - { - continue; - } - - if (field.FieldType == typeof(StructureVersion)) - { - var version = - type.GetCustomAttributes(typeof(StructureVersionAttribute), true) - .Cast() - .FirstOrDefault()? - .VersionNumber; - field.SetValue(instance, - version.HasValue ? new StructureVersion(version.Value, type) : new StructureVersion()); - } - else if (field.FieldType.IsArray) - { - var size = - field.GetCustomAttributes(typeof(MarshalAsAttribute), false) - .Cast() - .FirstOrDefault(attribute => attribute.Value != UnmanagedType.LPArray)? - .SizeConst; - var arrayType = field.FieldType.GetElementType(); - var array = Array.CreateInstance( - arrayType ?? throw new InvalidOperationException("Field type is null."), size ?? 0); - - if (arrayType.IsValueType) - { - for (var i = 0; i < array.Length; i++) - { - var obj = arrayType.Instantiate(); - array.SetValue(obj, i); - } - } - - field.SetValue(instance, array); - } - else if (field.FieldType == typeof(string)) - { - var isByVal = field.GetCustomAttributes(typeof(MarshalAsAttribute), false) - .Cast() - .Any(attribute => attribute.Value == UnmanagedType.ByValTStr); - - if (isByVal) - { - field.SetValue(instance, string.Empty); - } - } - else if (field.FieldType.IsValueType) - { - var isByRef = field.GetCustomAttributes(typeof(MarshalAsAttribute), false) - .Cast() - .Any(attribute => attribute.Value == UnmanagedType.LPStruct); - - if (!isByRef) - { - var value = field.FieldType.Instantiate(); - field.SetValue(instance, value); - } - } - } - } - } - catch - { - // ignored - } - - return (T) instance; - } - - public static T[] Repeat(this T structure, int count) - { - return Enumerable.Range(0, count).Select(i => structure).ToArray(); - } - - public static T SetBit(this T integer, int index, bool value) where T : struct, IConvertible - { - var bigInteger = BitWiseConvert(integer); - - var mask = 1ul << index; - var newInteger = value ? bigInteger | mask : bigInteger & ~mask; - - return BitWiseConvert(newInteger); - } - - // ReSharper disable once TooManyArguments - public static T SetBits(this T integer, int index, int count, ulong value) where T : struct, IConvertible - { - var bigInteger = BitWiseConvert(integer); - - count = 64 - count; - value <<= count; - value >>= count - index; - - bigInteger |= value; - - return BitWiseConvert(bigInteger); - } - - public static byte[] ToByteArray(this T structure) where T : struct - { - var size = Marshal.SizeOf(typeof(T)); - var array = new byte[size]; - var pointer = Marshal.AllocHGlobal(size); - - try - { - Marshal.StructureToPtr(structure, pointer, true); - Marshal.Copy(pointer, array, 0, size); - - return array; - } - finally - { - Marshal.FreeHGlobal(pointer); - } - } - - public static T ToStructure(this byte[] byteArray) where T : struct - { - var size = Marshal.SizeOf(typeof(T)); - var pointer = Marshal.AllocHGlobal(size); - - try - { - Marshal.Copy(byteArray, 0, pointer, Math.Min(byteArray.Length, size)); - - return (T) Marshal.PtrToStructure(pointer, typeof(T)); - } - finally - { - Marshal.FreeHGlobal(pointer); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/FunctionId.cs b/app/NvAPIWrapper/Native/Helpers/FunctionId.cs deleted file mode 100644 index 446f8b48..00000000 --- a/app/NvAPIWrapper/Native/Helpers/FunctionId.cs +++ /dev/null @@ -1,709 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace NvAPIWrapper.Native.Helpers -{ - [SuppressMessage("ReSharper", "InconsistentNaming")] - internal enum FunctionId : uint - { - // ------------------------------------------------- - // Public NvAPI Functions - // ------------------------------------------------- - - #region Public NvAPI Functions - - NvAPI_CreateDisplayFromUnAttachedDisplay = 0x63F9799E, - NvAPI_D3D_BeginResourceRendering = 0x91123D6A, - NvAPI_D3D_ConfigureAnsel = 0x341C6C7F, - NvAPI_D3D_CreateLateLatchObject = 0x2DB27D09, - NvAPI_D3D_EndResourceRendering = 0x37E7191C, - NvAPI_D3D_GetCurrentSLIState = 0x4B708B54, - NvAPI_D3D_GetObjectHandleForResource = 0xFCEAC864, - NvAPI_D3D_ImplicitSLIControl = 0x2AEDE111, - NvAPI_D3D_InitializeSMPAssist = 0x42763D0C, - NvAPI_D3D_IsGSyncActive = 0xE942B0FF, - NvAPI_D3D_IsGSyncCapable = 0x9C1EED78, - NvAPI_D3D_QueryLateLatchSupport = 0x8CECA0EC, - NvAPI_D3D_QueryModifiedWSupport = 0xCBF9F4F5, - NvAPI_D3D_QueryMultiViewSupport = 0xB6E0A41C, - NvAPI_D3D_QuerySinglePassStereoSupport = 0x6F5F0A6D, - NvAPI_D3D_QuerySMPAssistSupport = 0xC57921DE, - NvAPI_D3D_RegisterDevice = 0x8C02C4D0, - NvAPI_D3D_SetFPSIndicatorState = 0xA776E8DB, - NvAPI_D3D_SetModifiedWMode = 0x6EA4BF4, - NvAPI_D3D_SetMultiViewMode = 0x8285C8DA, - NvAPI_D3D_SetResourceHint = 0x6C0ED98C, - NvAPI_D3D_SetSinglePassStereoMode = 0xA39E6E6E, - NvAPI_D3D10_SetDepthBoundsTest = 0x4EADF5D2, - NvAPI_D3D11_AliasMSAATexture2DAsNonMSAA = 0xF1C54FC9, - NvAPI_D3D11_BeginUAVOverlap = 0x65B93CA8, - NvAPI_D3D11_BeginUAVOverlapEx = 0xBA08208A, - NvAPI_D3D11_CopyTileMappings = 0xC09EE6BC, - NvAPI_D3D11_CreateDevice = 0x6A16D3A0, - NvAPI_D3D11_CreateDeviceAndSwapChain = 0xBB939EE5, - NvAPI_D3D11_CreateDomainShaderEx = 0xA0D7180D, - NvAPI_D3D11_CreateFastGeometryShader = 0x525D43BE, - NvAPI_D3D11_CreateFastGeometryShaderExplicit = 0x71AB7C9C, - NvAPI_D3D11_CreateGeometryShaderEx_2 = 0x99ED5C1C, - NvAPI_D3D11_CreateHullShaderEx = 0xB53CAB00, - NvAPI_D3D11_CreateMultiGPUDevice = 0xBDB20007, - NvAPI_D3D11_CreatePixelShaderEx_2 = 0x4162822B, - NvAPI_D3D11_CreateRasterizerState = 0xDB8D28AF, - NvAPI_D3D11_CreateShadingRateResourceView = 0x99CA2DFF, - NvAPI_D3D11_CreateTiledTexture2DArray = 0x7886981A, - NvAPI_D3D11_CreateVertexShaderEx = 0xBEAA0B2, - NvAPI_D3D11_EndUAVOverlap = 0x2216A357, - NvAPI_D3D11_IsNvShaderExtnOpCodeSupported = 0x5F68DA40, - NvAPI_D3D11_MultiDrawIndexedInstancedIndirect = 0x59E890F9, - NvAPI_D3D11_MultiDrawInstancedIndirect = 0xD4E26BBF, - NvAPI_D3D11_MultiGPU_GetCaps = 0xD2D25687, - NvAPI_D3D11_MultiGPU_Init = 0x17BE49E, - NvAPI_D3D11_RSGetPixelShadingRateSampleOrder = 0x92442A1, - NvAPI_D3D11_RSSetExclusiveScissorRects = 0xAE4D73EF, - NvAPI_D3D11_RSSetPixelShadingRateSampleOrder = 0xA942373A, - NvAPI_D3D11_RSSetShadingRateResourceView = 0x1B0C2F83, - NvAPI_D3D11_RSSetViewportsPixelShadingRates = 0x34F7938F, - NvAPI_D3D11_SetDepthBoundsTest = 0x7AAF7A04, - NvAPI_D3D11_SetNvShaderExtnSlot = 0x8E90BB9F, - NvAPI_D3D11_SetNvShaderExtnSlotLocalThread = 0xE6482A0, - NvAPI_D3D11_TiledResourceBarrier = 0xD6839099, - NvAPI_D3D11_TiledTexture2DArrayGetDesc = 0xF1A2B9D5, - NvAPI_D3D11_UpdateTileMappings = 0x9A06EA07, - NvAPI_D3D12_CopyTileMappings = 0x47F78194, - NvAPI_D3D12_CreateComputePipelineState = 0x2762DEAC, - NvAPI_D3D12_CreateGraphicsPipelineState = 0x2FC28856, - NvAPI_D3D12_CreateHeap = 0x5CB397CF, - NvAPI_D3D12_CreateReservedResource = 0x2C85F101, - NvAPI_D3D12_IsNvShaderExtnOpCodeSupported = 0x3DFACEC8, - NvAPI_D3D12_Mosaic_GetCompanionAllocations = 0xA46022C7, - NvAPI_D3D12_Mosaic_GetViewportAndGpuPartitions = 0xB092B818, - NvAPI_D3D12_QueryModifiedWSupport = 0x51235248, - NvAPI_D3D12_QuerySinglePassStereoSupport = 0x3B03791B, - NvAPI_D3D12_ReservedResourceGetDesc = 0x9AA2AABB, - NvAPI_D3D12_ResourceAliasingBarrier = 0xB942BAB7, - NvAPI_D3D12_SetDepthBoundsTestValues = 0xB9333FE9, - NvAPI_D3D12_SetModifiedWMode = 0xE1FDABA7, - NvAPI_D3D12_SetSinglePassStereoMode = 0x83556D87, - NvAPI_D3D12_UpdateTileMappings = 0xC6017A7D, - NvAPI_D3D12_UseDriverHeapPriorities = 0xF0D978A8, - NvAPI_D3D1x_CreateSwapChain = 0x1BC21B66, - NvAPI_D3D1x_DisableShaderDiskCache = 0xD0CBCA7D, - NvAPI_D3D1x_GetGraphicsCapabilities = 0x52B1499A, - NvAPI_D3D9_AliasSurfaceAsTexture = 0xE5CEAE41, - NvAPI_D3D9_ClearRT = 0x332D3942, - NvAPI_D3D9_CreateSwapChain = 0x1A131E09, - NvAPI_D3D9_GetSurfaceHandle = 0xF2DD3F2, - NvAPI_D3D9_RegisterResource = 0xA064BDFC, - NvAPI_D3D9_StretchRectEx = 0x22DE03AA, - NvAPI_D3D9_UnregisterResource = 0xBB2B17AA, - NvAPI_D3D9_VideoSetStereoInfo = 0xB852F4DB, - NvAPI_DisableHWCursor = 0xAB163097, - NvAPI_Disp_ColorControl = 0x92F9D80D, - NvAPI_DISP_DeleteCustomDisplay = 0x552E5B9B, - NvAPI_DISP_EnumCustomDisplay = 0xA2072D59, - NvAPI_DISP_GetAssociatedUnAttachedNvidiaDisplayHandle = 0xA70503B2, - NvAPI_DISP_GetDisplayConfig = 0x11ABCCF8, - NvAPI_DISP_GetDisplayIdByDisplayName = 0xAE457190, - NvAPI_DISP_GetGDIPrimaryDisplayId = 0x1E9D8A31, - NvAPI_Disp_GetHdrCapabilities = 0x84F2A8DF, - NvAPI_DISP_GetMonitorCapabilities = 0x3B05C7E1, - NvAPI_DISP_GetMonitorColorCapabilities = 0x6AE4CFB5, - NvAPI_DISP_GetTiming = 0x175167E9, - NvAPI_Disp_HdrColorControl = 0x351DA224, - NvAPI_Disp_InfoFrameControl = 0x6067AF3F, - NvAPI_DISP_RevertCustomDisplayTrial = 0xCBBD40F0, - NvAPI_DISP_SaveCustomDisplay = 0x49882876, - NvAPI_DISP_SetDisplayConfig = 0x5D8CF8DE, - NvAPI_DISP_TryCustomDisplay = 0x1F7DB630, - NvAPI_DRS_CreateApplication = 0x4347A9DE, - NvAPI_DRS_CreateProfile = 0xCC176068, - NvAPI_DRS_CreateSession = 0x694D52E, - NvAPI_DRS_DeleteApplication = 0x2C694BC6, - NvAPI_DRS_DeleteApplicationEx = 0xC5EA85A1, - NvAPI_DRS_DeleteProfile = 0x17093206, - NvAPI_DRS_DeleteProfileSetting = 0xE4A26362, - NvAPI_DRS_DestroySession = 0xDAD9CFF8, - NvAPI_DRS_EnumApplications = 0x7FA2173A, - NvAPI_DRS_EnumAvailableSettingIds = 0xF020614A, - NvAPI_DRS_EnumAvailableSettingValues = 0x2EC39F90, - NvAPI_DRS_EnumProfiles = 0xBC371EE0, - NvAPI_DRS_EnumSettings = 0xAE3039DA, - NvAPI_DRS_FindApplicationByName = 0xEEE566B2, - NvAPI_DRS_FindProfileByName = 0x7E4A9A0B, - NvAPI_DRS_GetApplicationInfo = 0xED1F8C69, - NvAPI_DRS_GetBaseProfile = 0xDA8466A0, - NvAPI_DRS_GetCurrentGlobalProfile = 0x617BFF9F, - NvAPI_DRS_GetNumProfiles = 0x1DAE4FBC, - NvAPI_DRS_GetProfileInfo = 0x61CD6FD6, - NvAPI_DRS_GetSetting = 0x73BF8338, - NvAPI_DRS_GetSettingIdFromName = 0xCB7309CD, - NvAPI_DRS_GetSettingNameFromId = 0xD61CBE6E, - NvAPI_DRS_LoadSettings = 0x375DBD6B, - NvAPI_DRS_LoadSettingsFromFile = 0xD3EDE889, - NvAPI_DRS_RestoreAllDefaults = 0x5927B094, - NvAPI_DRS_RestoreProfileDefault = 0xFA5F6134, - NvAPI_DRS_RestoreProfileDefaultSetting = 0x53F0381E, - NvAPI_DRS_SaveSettings = 0xFCBC7E14, - NvAPI_DRS_SaveSettingsToFile = 0x2BE25DF8, - NvAPI_DRS_SetCurrentGlobalProfile = 0x1C89C5DF, - NvAPI_DRS_SetProfileInfo = 0x16ABD3A9, - NvAPI_DRS_SetSetting = 0x577DD202, - NvAPI_EnableCurrentMosaicTopology = 0x74073CC9, - NvAPI_EnableHWCursor = 0x2863148D, - NvAPI_EnumLogicalGPUs = 0x48B3EA59, - NvAPI_EnumNvidiaDisplayHandle = 0x9ABDD40D, - NvAPI_EnumNvidiaUnAttachedDisplayHandle = 0x20DE9260, - NvAPI_EnumPhysicalGPUs = 0xE5AC921F, - NvAPI_EnumTCCPhysicalGPUs = 0xD9930B07, - NvAPI_GetAssociatedDisplayOutputId = 0xD995937E, - NvAPI_GetAssociatedNvidiaDisplayHandle = 0x35C29134, - NvAPI_GetAssociatedNvidiaDisplayName = 0x22A78B05, - NvAPI_GetCurrentMosaicTopology = 0xF60852BD, - NvAPI_GetDisplayDriverVersion = 0xF951A4D1, - NvAPI_GetDisplayPortInfo = 0xC64FF367, - NvAPI_GetErrorMessage = 0x6C2D048C, - NvAPI_GetHDMISupportInfo = 0x6AE16EC3, - NvAPI_GetInterfaceVersionString = 0x1053FA5, - NvAPI_GetLogicalGPUFromDisplay = 0xEE1370CF, - NvAPI_GetLogicalGPUFromPhysicalGPU = 0xADD604D1, - NvAPI_GetPhysicalGPUFromUnAttachedDisplay = 0x5018ED61, - NvAPI_GetPhysicalGPUsFromDisplay = 0x34EF9506, - NvAPI_GetPhysicalGPUsFromLogicalGPU = 0xAEA3FA32, - NvAPI_GetSupportedMosaicTopologies = 0x410B5C25, - NvAPI_GetSupportedViews = 0x66FB7FC0, - NvAPI_GetUnAttachedAssociatedDisplayName = 0x4888D790, - NvAPI_GetVBlankCounter = 0x67B5DB55, - NvAPI_GetView = 0xD6B99D89, - NvAPI_GetViewEx = 0xDBBC0AF4, - NvAPI_GPU_ClientIllumDevicesGetControl = 0x73C01D58, - NvAPI_GPU_ClientIllumDevicesGetInfo = 0xD4100E58, - NvAPI_GPU_ClientIllumDevicesSetControl = 0x57024C62, - NvAPI_GPU_ClientIllumZonesGetControl = 0x3DBF5764, - NvAPI_GPU_ClientIllumZonesGetInfo = 0x4B81241B, - NvAPI_GPU_ClientIllumZonesSetControl = 0x197D065E, - NvAPI_GPU_GetActiveOutputs = 0xE3E89B6F, - NvAPI_GPU_GetAGPAperture = 0x6E042794, - NvAPI_GPU_GetAllClockFrequencies = 0xDCB616C3, - NvAPI_GPU_GetAllDisplayIds = 0x785210A2, - NvAPI_GPU_GetAllOutputs = 0x7D554F8E, - NvAPI_GPU_GetBoardInfo = 0x22D54523, - NvAPI_GPU_GetBusId = 0x1BE0B8E5, - NvAPI_GPU_GetBusSlotId = 0x2A0A350F, - NvAPI_GPU_GetBusType = 0x1BB18724, - NvAPI_GPU_GetConnectedDisplayIds = 0x78DBA2, - NvAPI_GPU_GetConnectedOutputs = 0x1730BFC9, - NvAPI_GPU_GetConnectedOutputsWithLidState = 0xCF8CAF39, - NvAPI_GPU_GetConnectedSLIOutputs = 0x680DE09, - NvAPI_GPU_GetConnectedSLIOutputsWithLidState = 0x96043CC7, - NvAPI_GPU_GetCurrentAGPRate = 0xC74925A0, - NvAPI_GPU_GetCurrentPCIEDownstreamWidth = 0xD048C3B1, - NvAPI_GPU_GetCurrentPstate = 0x927DA4F6, - NvAPI_GPU_GetDynamicPstatesInfoEx = 0x60DED2ED, - NvAPI_GPU_GetECCConfigurationInfo = 0x77A796F3, - NvAPI_GPU_GetECCErrorInfo = 0xC71F85A6, - NvAPI_GPU_GetECCStatusInfo = 0xCA1DDAF3, - NvAPI_GPU_GetEDID = 0x37D32E69, - NvAPI_GPU_GetFullName = 0xCEEE8E9F, - NvAPI_GPU_GetGpuCoreCount = 0xC7026A87, - NvAPI_GPU_GetGPUType = 0xC33BAEB1, - NvAPI_GPU_GetHDCPSupportStatus = 0xF089EEF5, - NvAPI_GPU_GetIllumination = 0x9A1B9365, - NvAPI_GPU_GetIRQ = 0xE4715417, - NvAPI_GPU_GetMemoryInfo = 0x7F9B368, - NvAPI_GPU_GetOutputType = 0x40A505E4, - NvAPI_GPU_GetPCIIdentifiers = 0x2DDFB66E, - NvAPI_GPU_GetPerfDecreaseInfo = 0x7F7F4600, - NvAPI_GPU_GetPhysicalFrameBufferSize = 0x46FBEB03, - NvAPI_GPU_GetPstates20 = 0x6FF81213, - NvAPI_GPU_GetPstatesInfoEx = 0x843C0256, - NvAPI_GPU_GetQuadroStatus = 0xE332FA47, - NvAPI_GPU_GetScanoutCompositionParameter = 0x58FE51E6, - NvAPI_GPU_GetScanoutConfiguration = 0x6A9F5B63, - NvAPI_GPU_GetScanoutConfigurationEx = 0xE2E1E6F0, - NvAPI_GPU_GetScanoutIntensityState = 0xE81CE836, - NvAPI_GPU_GetScanoutWarpingState = 0x6F5435AF, - NvAPI_GPU_GetShaderSubPipeCount = 0xBE17923, - NvAPI_GPU_GetSystemType = 0xBAAABFCC, - NvAPI_GPU_GetTachReading = 0x5F608315, - NvAPI_GPU_GetThermalSettings = 0xE3640A56, - NvAPI_GPU_GetVbiosOEMRevision = 0x2D43FB31, - NvAPI_GPU_GetVbiosRevision = 0xACC3DA0A, - NvAPI_GPU_GetVbiosVersionString = 0xA561FD7D, - NvAPI_GPU_GetVirtualFrameBufferSize = 0x5A04B644, - NvAPI_GPU_QueryIlluminationSupport = 0xA629DA31, - NvAPI_GPU_ResetECCErrorInfo = 0xC02EEC20, - NvAPI_GPU_SetECCConfiguration = 0x1CF639D9, - NvAPI_GPU_SetEDID = 0xE83D6456, - NvAPI_GPU_SetIllumination = 0x254A187, - NvAPI_GPU_SetScanoutCompositionParameter = 0xF898247D, - NvAPI_GPU_SetScanoutIntensity = 0xA57457A4, - NvAPI_GPU_SetScanoutWarping = 0xB34BAB4F, - NvAPI_GPU_ValidateOutputCombination = 0x34C9C2D4, - NvAPI_GPU_WorkstationFeatureQuery = 0x4537DF, - NvAPI_GPU_WorkstationFeatureSetup = 0x6C1F3FE4, - NvAPI_GSync_AdjustSyncDelay = 0x2D11FF51, - NvAPI_GSync_EnumSyncDevices = 0xD9639601, - NvAPI_GSync_GetControlParameters = 0x16DE1C6A, - NvAPI_GSync_GetStatusParameters = 0x70D404EC, - NvAPI_GSync_GetSyncStatus = 0xF1F5B434, - NvAPI_GSync_GetTopology = 0x4562BC38, - NvAPI_GSync_QueryCapabilities = 0x44A3F1D1, - NvAPI_GSync_SetControlParameters = 0x8BBFF88B, - NvAPI_GSync_SetSyncStateSettings = 0x60ACDFDD, - NvAPI_I2CRead = 0x2FDE12C5, - NvAPI_I2CWrite = 0xE812EB07, - NvAPI_Mosaic_EnableCurrentTopo = 0x5F1AA66C, - NvAPI_Mosaic_EnumDisplayGrids = 0xDF2887AF, - NvAPI_Mosaic_EnumDisplayModes = 0x78DB97D7, - NvAPI_Mosaic_GetCurrentTopo = 0xEC32944E, - NvAPI_Mosaic_GetDisplayViewportsByResolution = 0xDC6DC8D3, - NvAPI_Mosaic_GetOverlapLimits = 0x989685F0, - NvAPI_Mosaic_GetSupportedTopoInfo = 0xFDB63C81, - NvAPI_Mosaic_GetTopoGroup = 0xCB89381D, - NvAPI_Mosaic_SetCurrentTopo = 0x9B542831, - NvAPI_Mosaic_SetDisplayGrids = 0x4D959A89, - NvAPI_Mosaic_ValidateDisplayGrids = 0xCF43903D, - NvAPI_OGL_ExpertModeDefaultsGet = 0xAE921F12, - NvAPI_OGL_ExpertModeDefaultsSet = 0xB47A657E, - NvAPI_OGL_ExpertModeGet = 0x22ED9516, - NvAPI_OGL_ExpertModeSet = 0x3805EF7A, - NvAPI_SetCurrentMosaicTopology = 0xD54B8989, - NvAPI_SetDisplayPort = 0xFA13E65A, - NvAPI_SetRefreshRateOverride = 0x3092AC32, - NvAPI_SetView = 0x957D7B6, - NvAPI_SetViewEx = 0x6B89E68, - NvAPI_Stereo_Activate = 0xF6A1AD68, - NvAPI_Stereo_CaptureJpegImage = 0x932CB140, - NvAPI_Stereo_CapturePngImage = 0x8B7E99B5, - NvAPI_Stereo_CreateConfigurationProfileRegistryKey = 0xBE7692EC, - NvAPI_Stereo_CreateHandleFromIUnknown = 0xAC7E37F4, - NvAPI_Stereo_Deactivate = 0x2D68DE96, - NvAPI_Stereo_Debug_WasLastDrawStereoized = 0xED4416C5, - NvAPI_Stereo_DecreaseConvergence = 0x4C87E317, - NvAPI_Stereo_DecreaseSeparation = 0xDA044458, - NvAPI_Stereo_DeleteConfigurationProfileRegistryKey = 0xF117B834, - NvAPI_Stereo_DeleteConfigurationProfileValue = 0x49BCEECF, - NvAPI_Stereo_DestroyHandle = 0x3A153134, - NvAPI_Stereo_Disable = 0x2EC50C2B, - NvAPI_Stereo_Enable = 0x239C4545, - NvAPI_Stereo_GetConvergence = 0x4AB00934, - NvAPI_Stereo_GetDefaultProfile = 0x624E21C2, - NvAPI_Stereo_GetEyeSeparation = 0xCE653127, - NvAPI_Stereo_GetFrustumAdjustMode = 0xE6839B43, - NvAPI_Stereo_GetSeparation = 0x451F2134, - NvAPI_Stereo_GetStereoSupport = 0x296C434D, - NvAPI_Stereo_GetSurfaceCreationMode = 0x36F1C736, - NvAPI_Stereo_IncreaseConvergence = 0xA17DAABE, - NvAPI_Stereo_IncreaseSeparation = 0xC9A8ECEC, - NvAPI_Stereo_InitActivation = 0xC7177702, - NvAPI_Stereo_IsActivated = 0x1FB0BC30, - NvAPI_Stereo_IsEnabled = 0x348FF8E1, - NvAPI_Stereo_IsWindowedModeSupported = 0x40C8ED5E, - NvAPI_Stereo_ReverseStereoBlitControl = 0x3CD58F89, - NvAPI_Stereo_SetActiveEye = 0x96EEA9F8, - NvAPI_Stereo_SetConfigurationProfileValue = 0x24409F48, - NvAPI_Stereo_SetConvergence = 0x3DD6B54B, - NvAPI_Stereo_SetDefaultProfile = 0x44F0ECD1, - NvAPI_Stereo_SetDriverMode = 0x5E8F0BEC, - NvAPI_Stereo_SetFrustumAdjustMode = 0x7BE27FA2, - NvAPI_Stereo_SetNotificationMessage = 0x6B9B409E, - NvAPI_Stereo_SetSeparation = 0x5C069FA3, - NvAPI_Stereo_SetSurfaceCreationMode = 0xF5DCFCBA, - NvAPI_Stereo_Trigger_Activation = 0xD6C6CD2, - NvAPI_SYS_GetChipSetInfo = 0x53DABBCA, - NvAPI_SYS_GetDisplayIdFromGpuAndOutputId = 0x8F2BAB4, - NvAPI_SYS_GetDriverAndBranchVersion = 0x2926AAAD, - NvAPI_SYS_GetGpuAndOutputIdFromDisplayId = 0x112BA1A5, - NvAPI_SYS_GetLidAndDockInfo = 0xCDA14D8A, - NvAPI_SYS_GetPhysicalGpuFromDisplayId = 0x9EA74659, - NvAPI_VIO_Close = 0xD01BD237, - NvAPI_VIO_EnumDataFormats = 0x221FA8E8, - NvAPI_VIO_EnumDevices = 0xFD7C5557, - NvAPI_VIO_EnumSignalFormats = 0xEAD72FE4, - NvAPI_VIO_GetCapabilities = 0x1DC91303, - NvAPI_VIO_GetConfig = 0xD34A789B, - NvAPI_VIO_GetCSC = 0x7B0D72A3, - NvAPI_VIO_GetGamma = 0x51D53D06, - NvAPI_VIO_GetPCIInfo = 0xB981D935, - NvAPI_VIO_GetSyncDelay = 0x462214A9, - NvAPI_VIO_IsFrameLockModeCompatible = 0x7BF0A94D, - NvAPI_VIO_IsRunning = 0x96BD040E, - NvAPI_VIO_Open = 0x44EE4841, - NvAPI_VIO_QueryTopology = 0x869534E2, - NvAPI_VIO_SetConfig = 0xE4EEC07, - NvAPI_VIO_SetCSC = 0xA1EC8D74, - NvAPI_VIO_SetGamma = 0x964BF452, - NvAPI_VIO_SetSyncDelay = 0x2697A8D1, - NvAPI_VIO_Start = 0xCDE8E1A3, - NvAPI_VIO_Status = 0xE6CE4F1, - NvAPI_VIO_Stop = 0x6BA2A5D6, - NvAPI_VIO_SyncFormatDetect = 0x118D48A3, - - #endregion - - // ------------------------------------------------- - // Private Internal NvAPI Functions - // ------------------------------------------------- - - #region Private Internal NvAPI Functions - - NvAPI_3D_GetProperty = 0x8061A4B1, - NvAPI_3D_GetPropertyRange = 0x0B85DE27C, - NvAPI_3D_SetProperty = 0x0C9175E8D, - NvAPI_AccessDisplayDriverRegistry = 0xF5579360, - NvAPI_Coproc_GetApplicationCoprocInfo = 0x79232685, - NvAPI_Coproc_GetCoprocInfoFlagsEx = 0x69A9874D, - NvAPI_Coproc_GetCoprocStatus = 0x1EFC3957, - NvAPI_Coproc_NotifyCoprocPowerState = 0x0CADCB956, - NvAPI_Coproc_SetCoprocInfoFlagsEx = 0x0F4C863AC, - NvAPI_CreateUnAttachedDisplayFromDisplay = 0xA0C72EE4, - NvAPI_D3D_CreateQuery = 0x5D19BCA4, - NvAPI_D3D_DestroyQuery = 0x0C8FF7258, - NvAPI_D3D_Query_Begin = 0x0E5A9AAE0, - NvAPI_D3D_Query_End = 0x2AC084FA, - NvAPI_D3D_Query_GetData = 0x0F8B53C69, - NvAPI_D3D_Query_GetDataSize = 0x0F2A54796, - NvAPI_D3D_Query_GetType = 0x4ACEEAF7, - NvAPI_D3D_RegisterApp = 0x0D44D3C4E, - NvAPI_D3D10_AliasPrimaryAsTexture = 0x8AAC133D, - NvAPI_D3D10_BeginShareResource = 0x35233210, - NvAPI_D3D10_BeginShareResourceEx = 0x0EF303A9D, - NvAPI_D3D10_CreateDevice = 0x2DE11D61, - NvAPI_D3D10_CreateDeviceAndSwapChain = 0x5B803DAF, - NvAPI_D3D10_EndShareResource = 0x0E9C5853, - NvAPI_D3D10_GetRenderedCursorAsBitmap = 0x0CAC3CE5D, - NvAPI_D3D10_ProcessCallbacks = 0x0AE9C2019, - NvAPI_D3D10_SetPrimaryFlipChainCallbacks = 0x73EB9329, - NvAPI_D3D11_BeginShareResource = 0x121BDC6, - NvAPI_D3D11_EndShareResource = 0x8FFB8E26, - NvAPI_D3D1x_BindSwapBarrier = 0x9DE8C729, - NvAPI_D3D1x_IFR_SetUpTargetBufferToSys = 0x473F7828, - NvAPI_D3D1x_IFR_TransferRenderTarget = 0x9FBAE4EB, - NvAPI_D3D1x_JoinSwapGroup = 0x14610CD7, - NvAPI_D3D1x_Present = 0x3B845A1, - NvAPI_D3D1x_QueryFrameCount = 0x9152E055, - NvAPI_D3D1x_QueryMaxSwapGroup = 0x9BB9D68F, - NvAPI_D3D1x_QuerySwapGroup = 0x407F67AA, - NvAPI_D3D1x_ResetFrameCount = 0x0FBBB031A, - NvAPI_D3D9_AliasPrimaryAsTexture = 0x13C7112E, - NvAPI_D3D9_AliasPrimaryFromDevice = 0x7C20C5BE, - NvAPI_D3D9_BindSwapBarrier = 0x9C39C246, - NvAPI_D3D9_CreatePathContextNV = 0x0A342F682, - NvAPI_D3D9_CreatePathNV = 0x71329DF3, - NvAPI_D3D9_CreateRenderTarget = 0x0B3827C8, - NvAPI_D3D9_CreateTexture = 0x0D5E13573, - NvAPI_D3D9_CreateVideo = 0x89FFD9A3, - NvAPI_D3D9_CreateVideoBegin = 0x84C9D553, - NvAPI_D3D9_CreateVideoEnd = 0x0B476BF61, - NvAPI_D3D9_DeletePathNV = 0x73E0019A, - NvAPI_D3D9_DestroyPathContextNV = 0x667C2929, - NvAPI_D3D9_DMA = 0x962B8AF6, - NvAPI_D3D9_DrawPathNV = 0x13199B3D, - NvAPI_D3D9_EnableStereo = 0x492A6954, - NvAPI_D3D9_EnumVideoFeatures = 0x1DB7C52C, - NvAPI_D3D9_FreeVideo = 0x3111BED1, - NvAPI_D3D9_GetCurrentRenderTargetHandle = 0x22CAD61, - NvAPI_D3D9_GetCurrentZBufferHandle = 0x0B380F218, - NvAPI_D3D9_GetIndexBufferHandle = 0x0FC5A155B, - NvAPI_D3D9_GetOverlaySurfaceHandles = 0x6800F5FC, - NvAPI_D3D9_GetSLIInfo = 0x694BFF4D, - NvAPI_D3D9_GetTextureHandle = 0x0C7985ED5, - NvAPI_D3D9_GetVertexBufferHandle = 0x72B19155, - NvAPI_D3D9_GetVideoCapabilities = 0x3D596B93, - NvAPI_D3D9_GetVideoState = 0x0A4527BF8, - NvAPI_D3D9_GPUBasedCPUSleep = 0x0D504DDA7, - NvAPI_D3D9_GpuSyncAcquire = 0x0D00B8317, - NvAPI_D3D9_GpuSyncEnd = 0x754033F0, - NvAPI_D3D9_GpuSyncGetHandleSize = 0x80C9FD3B, - NvAPI_D3D9_GpuSyncInit = 0x6D6FDAD4, - NvAPI_D3D9_GpuSyncMapIndexBuffer = 0x12EE68F2, - NvAPI_D3D9_GpuSyncMapSurfaceBuffer = 0x2AB714AB, - NvAPI_D3D9_GpuSyncMapTexBuffer = 0x0CDE4A28A, - NvAPI_D3D9_GpuSyncMapVertexBuffer = 0x0DBC803EC, - NvAPI_D3D9_GpuSyncRelease = 0x3D7A86BB, - NvAPI_D3D9_IFR_SetUpTargetBufferToNV12BLVideoSurface = 0x0CFC92C15, - NvAPI_D3D9_IFR_SetUpTargetBufferToSys = 0x55255D05, - NvAPI_D3D9_IFR_TransferRenderTarget = 0x0AB7C2DC, - NvAPI_D3D9_IFR_TransferRenderTargetToNV12BLVideoSurface = 0x5FE72F64, - NvAPI_D3D9_JoinSwapGroup = 0x7D44BB54, - NvAPI_D3D9_Lock = 0x6317345C, - NvAPI_D3D9_NVFBC_GetStatus = 0x0bd3eb475, - NvAPI_D3D9_PathClearDepthNV = 0x157E45C4, - NvAPI_D3D9_PathDepthNV = 0x0FCB16330, - NvAPI_D3D9_PathEnableColorWriteNV = 0x3E2804A2, - NvAPI_D3D9_PathEnableDepthTestNV = 0x0E99BA7F3, - NvAPI_D3D9_PathMatrixNV = 0x0D2F6C499, - NvAPI_D3D9_PathParameterfNV = 0x0F7FF00C1, - NvAPI_D3D9_PathParameteriNV = 0x0FC31236C, - NvAPI_D3D9_PathVerticesNV = 0x0C23DF926, - NvAPI_D3D9_Present = 0x5650BEB, - NvAPI_D3D9_PresentSurfaceToDesktop = 0x0F7029C5, - NvAPI_D3D9_PresentVideo = 0x5CF7F862, - NvAPI_D3D9_QueryAAOverrideMode = 0x0DDF5643C, - NvAPI_D3D9_QueryFrameCount = 0x9083E53A, - NvAPI_D3D9_QueryMaxSwapGroup = 0x5995410D, - NvAPI_D3D9_QuerySwapGroup = 0x0EBA4D232, - NvAPI_D3D9_QueryVideoInfo = 0x1E6634B3, - NvAPI_D3D9_ResetFrameCount = 0x0FA6A0675, - NvAPI_D3D9_SetGamutData = 0x2BBDA32E, - NvAPI_D3D9_SetPitchSurfaceCreation = 0x18CDF365, - NvAPI_D3D9_SetResourceHint = 0x905F5C27, - NvAPI_D3D9_SetSLIMode = 0x0BFDC062C, - NvAPI_D3D9_SetSurfaceCreationLayout = 0x5609B86A, - NvAPI_D3D9_SetVideoState = 0x0BD4BC56F, - NvAPI_D3D9_StretchRect = 0x0AEAECD41, - NvAPI_D3D9_Unlock = 0x0C182027E, - NvAPI_D3D9_VideoSurfaceEncryptionControl = 0x9D2509EF, - NvAPI_DeleteCustomDisplay = 0x0E7CB998D, - NvAPI_DeleteUnderscanConfig = 0x0F98854C8, - NvAPI_Disp_DpAuxChannelControl = 0x8EB56969, - NvAPI_DISP_EnumHDMIStereoModes = 0x0D2CCF5D6, - NvAPI_DISP_GetDisplayBlankingState = 0x63E5D8DB, - NvAPI_DISP_GetHCloneTopology = 0x47BAD137, - NvAPI_DISP_GetVirtualModeData = 0x3230D69A, - NvAPI_DISP_OverrideDisplayModeList = 0x291BFF2, - NvAPI_DISP_SetDisplayBlankingState = 0x1E17E29B, - NvAPI_DISP_SetHCloneTopology = 0x61041C24, - NvAPI_DISP_ValidateHCloneTopology = 0x5F4C2664, - NvAPI_EnumCustomDisplay = 0x42892957, - NvAPI_EnumUnderscanConfig = 0x4144111A, - NvAPI_Event_RegisterCallback = 0x0E6DBEA69, - NvAPI_Event_UnregisterCallback = 0x0DE1F9B45, - NvAPI_GetDisplayDriverBuildTitle = 0x7562E947, - NvAPI_GetDisplayDriverCompileType = 0x988AEA78, - NvAPI_GetDisplayDriverMemoryInfo = 0x774AA982, - NvAPI_GetDisplayDriverRegistryPath = 0x0E24CEEE, - NvAPI_GetDisplayDriverSecurityLevel = 0x9D772BBA, - NvAPI_GetDisplayFeatureConfig = 0x8E985CCD, - NvAPI_GetDisplayFeatureConfigDefaults = 0x0F5F4D01, - NvAPI_GetDisplayPosition = 0x6BB1EE5D, - NvAPI_GetDisplaySettings = 0x0DC27D5D4, - NvAPI_GetDriverMemoryInfo = 0x2DC95125, - NvAPI_GetDriverModel = 0x25EEB2C4, - NvAPI_GetDVCInfo = 0x4085DE45, - NvAPI_GetDVCInfoEx = 0x0E45002D, - NvAPI_GetGPUIDfromPhysicalGPU = 0x6533EA3E, - NvAPI_GetHDCPLinkParameters = 0x0B3BB0772, - NvAPI_GetHUEInfo = 0x95B64341, - NvAPI_GetHybridMode = 0x0E23B68C1, - NvAPI_GetImageSharpeningInfo = 0x9FB063DF, - NvAPI_GetInfoFrame = 0x9734F1D, - NvAPI_GetInfoFrameState = 0x41511594, - NvAPI_GetInfoFrameStatePvt = 0x7FC17574, - NvAPI_GetInvalidGpuTopologies = 0x15658BE6, - NvAPI_GetLoadedMicrocodePrograms = 0x919B3136, - NvAPI_GetPhysicalGPUFromDisplay = 0x1890E8DA, - NvAPI_GetPhysicalGPUFromGPUID = 0x5380AD1A, - NvAPI_GetPVExtName = 0x2F5B08E0, - NvAPI_GetPVExtProfile = 0x1B1B9A16, - NvAPI_GetScalingCaps = 0x8E875CF9, - NvAPI_GetTiming = 0x0AFC4833E, - NvAPI_GetTopologyDisplayGPU = 0x813D89A8, - NvAPI_GetTVEncoderControls = 0x5757474A, - NvAPI_GetTVOutputBorderColor = 0x6DFD1C8C, - NvAPI_GetTVOutputInfo = 0x30C805D5, - NvAPI_GetUnAttachedDisplayDriverRegistryPath = 0x633252D8, - NvAPI_GetValidGpuTopologies = 0x5DFAB48A, - NvAPI_GetVideoState = 0x1C5659CD, - NvAPI_GPS_GetPerfSensors = 0x271C1109, - NvAPI_GPS_GetPowerSteeringStatus = 0x540EE82E, - NvAPI_GPS_GetThermalLimit = 0x583113ED, - NvAPI_GPS_GetVPStateCap = 0x71913023, - NvAPI_GPS_SetPowerSteeringStatus = 0x9723D3A2, - NvAPI_GPS_SetThermalLimit = 0x0C07E210F, - NvAPI_GPS_SetVPStateCap = 0x68888EB4, - NvAPI_GPU_ClearPCIELinkAERInfo = 0x521566BB, - NvAPI_GPU_ClearPCIELinkErrorInfo = 0x8456FF3D, - NvAPI_GPU_ClientPowerPoliciesGetInfo = 0x34206D86, - NvAPI_GPU_ClientPowerPoliciesGetStatus = 0x70916171, - NvAPI_GPU_ClientPowerPoliciesSetStatus = 0x0AD95F5ED, - NvAPI_GPU_ClientPowerTopologyGetInfo = 0x0A4DFD3F2, - NvAPI_GPU_ClientPowerTopologyGetStatus = 0x0EDCF624E, - NvAPI_GPU_CudaEnumComputeCapableGpus = 0x5786CC6E, - NvAPI_GPU_EnableDynamicPstates = 0x0FA579A0F, - NvAPI_GPU_EnableOverclockedPstates = 0x0B23B70EE, - NvAPI_GPU_Get_DisplayPort_DongleInfo = 0x76A70E8D, - NvAPI_GPU_GetAllClocks = 0x1BD69F49, - NvAPI_GPU_GetAllGpusOnSameBoard = 0x4DB019E6, - NvAPI_GPU_GetArchInfo = 0xD8265D24, - NvAPI_GPU_GetBarInfo = 0xE4B701E3, - NvAPI_GPU_GetClockBoostLock = 0xe440b867, // unknown name, NVAPI_ID_CURVE_GET - NvAPI_GPU_GetClockBoostMask = 0x507b4b59, - NvAPI_GPU_GetClockBoostRanges = 0x64b43a6a, - NvAPI_GPU_GetClockBoostTable = 0x23f1b133, - NvAPI_GPU_GetColorSpaceConversion = 0x8159E87A, - NvAPI_GPU_GetConnectorInfo = 0x4ECA2C10, - NvAPI_GPU_GetCoolerPolicyTable = 0x518A32C, - NvAPI_GPU_GetCoolerSettings = 0x0DA141340, - NvAPI_GPU_GetCoreVoltageBoostPercent = 0x9df23ca1, - NvAPI_GPU_GetCurrentFanSpeedLevel = 0x0BD71F0C9, - NvAPI_GPU_GetCurrentThermalLevel = 0x0D2488B79, - NvAPI_GPU_GetCurrentVoltage = 0x465f9bcf, - NvAPI_GPU_GetDeepIdleState = 0x1AAD16B4, - NvAPI_GPU_GetDeviceDisplayMode = 0x0D2277E3A, - NvAPI_GPU_GetDisplayUnderflowStatus = 0xED9E8057, - NvAPI_GPU_GetDitherControl = 0x932AC8FB, - NvAPI_GPU_GetExtendedMinorRevision = 0x25F17421, - NvAPI_GPU_GetFBWidthAndLocation = 0x11104158, - NvAPI_GPU_GetFlatPanelInfo = 0x36CFF969, - NvAPI_GPU_GetFoundry = 0x5D857A00, - NvAPI_GPU_GetFrameBufferCalibrationLockFailures = 0x524B9773, - NvAPI_GPU_GetHardwareQualType = 0xF91E777B, - NvAPI_GPU_GetHybridControllerInfo = 0xD26B8A58, - NvAPI_GPU_GetLogicalFBWidthAndLocation = 0x8efc0978, - NvAPI_GPU_GetManufacturingInfo = 0xA4218928, - NvAPI_GPU_GetMemPartitionMask = 0x329D77CD, - NvAPI_GPU_GetMXMBlock = 0xB7AB19B9, - NvAPI_GPU_GetPartitionCount = 0x86F05D7A, - NvAPI_GPU_GetPCIEInfo = 0xE3795199, - NvAPI_GPU_GetPerfClocks = 0x1EA54A3B, - NvAPI_GPU_GetPerfHybridMode = 0x5D7CCAEB, - NvAPI_GPU_GetPerGpuTopologyStatus = 0x0A81F8992, - NvAPI_GPU_GetPixelClockRange = 0x66AF10B7, - NvAPI_GPU_GetPowerMizerInfo = 0x76BFA16B, - NvAPI_GPU_GetPSFloorSweepStatus = 0xDEE047AB, - NvAPI_GPU_GetPstateClientLimits = 0x88C82104, - NvAPI_GPU_GetPstatesInfo = 0x0BA94C56E, - NvAPI_GPU_GetRamBankCount = 0x17073A3C, - NvAPI_GPU_GetRamBusWidth = 0x7975C581, - NvAPI_GPU_GetRamConfigStrap = 0x51CCDB2A, - NvAPI_GPU_GetRamMaker = 0x42aea16a, - NvAPI_GPU_GetRamType = 0x57F7CAAC, - NvAPI_GPU_GetRawFuseData = 0xE0B1DCE9, - NvAPI_GPU_GetROPCount = 0xfdc129fa, - NvAPI_GPU_GetSampleType = 0x32E1D697, - NvAPI_GPU_GetSerialNumber = 0x14B83A5F, - NvAPI_GPU_GetShaderPipeCount = 0x63E2F56F, - NvAPI_GPU_GetShortName = 0xD988F0F3, - NvAPI_GPU_GetSMMask = 0x0EB7AF173, - NvAPI_GPU_GetTargetID = 0x35B5FD2F, - NvAPI_GPU_GetThermalPoliciesInfo = 0x00D258BB5, // NvAPI_GPU_ClientThermalPoliciesGetInfo - NvAPI_GPU_GetThermalPoliciesStatus = 0x0E9C425A1, - NvAPI_GPU_GetThermalTable = 0xC729203C, - NvAPI_GPU_GetTotalSMCount = 0x0AE5FBCFE, - NvAPI_GPU_GetTotalSPCount = 0x0B6D62591, - NvAPI_GPU_GetTotalTPCCount = 0x4E2F76A8, - NvAPI_GPU_GetTPCMask = 0x4A35DF54, - NvAPI_GPU_GetUsages = 0x189a1fdf, - NvAPI_GPU_GetVbiosImage = 0xFC13EE11, - NvAPI_GPU_GetVbiosMxmVersion = 0xE1D5DABA, - NvAPI_GPU_GetVFPCurve = 0x21537ad4, - NvAPI_GPU_GetVoltageDomainsStatus = 0x0C16C7E2C, - NvAPI_GPU_GetVoltages = 0x7D656244, - NvAPI_GPU_GetVoltageStep = 0x28766157, // unsure of the name - NvAPI_GPU_GetVPECount = 0xD8CBF37B, - NvAPI_GPU_GetVSFloorSweepStatus = 0xD4F3944C, - NvAPI_GPU_GPIOQueryLegalPins = 0x0FAB69565, - NvAPI_GPU_GPIOReadFromPin = 0x0F5E10439, - NvAPI_GPU_GPIOWriteToPin = 0x0F3B11E68, - NvAPI_GPU_PerfPoliciesGetInfo = 0x409d9841, - NvAPI_GPU_PerfPoliciesGetStatus = 0x3d358a0c, - NvAPI_GPU_PhysxQueryRecommendedState = 0x7A4174F4, - NvAPI_GPU_PhysxSetState = 0x4071B85E, - NvAPI_GPU_QueryActiveApps = 0x65B1C5F5, - NvAPI_GPU_RestoreCoolerPolicyTable = 0x0D8C4FE63, - NvAPI_GPU_RestoreCoolerSettings = 0x8F6ED0FB, - NvAPI_GPU_SetClockBoostLock = 0x39442cfb, // unknown name, NVAPI_ID_CURVE_SET - NvAPI_GPU_SetClockBoostTable = 0x0733e009, - NvAPI_GPU_SetClocks = 0x6F151055, - NvAPI_GPU_SetColorSpaceConversion = 0x0FCABD23A, - NvAPI_GPU_SetCoolerLevels = 0x891FA0AE, - NvAPI_GPU_SetCoolerPolicyTable = 0x987947CD, - NvAPI_GPU_SetCoreVoltageBoostPercent = 0xb9306d9b, - NvAPI_GPU_SetCurrentPCIESpeed = 0x3BD32008, - NvAPI_GPU_SetCurrentPCIEWidth = 0x3F28E1B9, - NvAPI_GPU_SetDeepIdleState = 0x568A2292, - NvAPI_GPU_SetDisplayUnderflowMode = 0x387B2E41, - NvAPI_GPU_SetDitherControl = 0x0DF0DFCDD, - NvAPI_GPU_SetPerfClocks = 0x7BCF4AC, - NvAPI_GPU_SetPerfHybridMode = 0x7BC207F8, - NvAPI_GPU_SetPixelClockRange = 0x5AC7F8E5, - NvAPI_GPU_SetPowerMizerInfo = 0x50016C78, - NvAPI_GPU_SetPstateClientLimits = 0x0FDFC7D49, - NvAPI_GPU_SetPstates20 = 0x0F4DAE6B, - NvAPI_GPU_SetPstatesInfo = 0x0CDF27911, - NvAPI_GPU_SetThermalPoliciesStatus = 0x034C0B13D, - NvAPI_Hybrid_IsAppMigrationStateChangeable = 0x584CB0B6, - NvAPI_Hybrid_QueryBlockedMigratableApps = 0x0F4C2F8CC, - NvAPI_Hybrid_QueryUnblockedNonMigratableApps = 0x5F35BCB5, - NvAPI_Hybrid_SetAppMigrationState = 0x0FA0B9A59, - NvAPI_I2CReadEx = 0x4D7B0709, - NvAPI_I2CWriteEx = 0x283AC65A, - NvAPI_LoadMicrocode = 0x3119F36E, - NvAPI_Mosaic_ChooseGpuTopologies = 0x0B033B140, - NvAPI_Mosaic_EnumGridTopologies = 0x0A3C55220, - NvAPI_Mosaic_GetDisplayCapabilities = 0x0D58026B9, - NvAPI_Mosaic_GetMosaicCapabilities = 0x0DA97071E, - NvAPI_Mosaic_GetMosaicViewports = 0x7EBA036, - NvAPI_Mosaic_SetGridTopology = 0x3F113C77, - NvAPI_Mosaic_ValidateDisplayGridsWithSLI = 0x1ECFD263, - NvAPI_QueryNonMigratableApps = 0x0BB9EF1C3, - NvAPI_QueryUnderscanCap = 0x61D7B624, - NvAPI_RestartDisplayDriver = 0xB4B26B65, - NvAPI_RevertCustomDisplayTrial = 0x854BA405, - NvAPI_SaveCustomDisplay = 0x0A9062C78, - NvAPI_SetDisplayFeatureConfig = 0x0F36A668D, - NvAPI_SetDisplayPosition = 0x57D9060F, - NvAPI_SetDisplaySettings = 0x0E04F3D86, - NvAPI_SetDVCLevel = 0x172409B4, - NvAPI_SetDVCLevelEx = 0x4A82C2B1, - NvAPI_SetFrameRateNotify = 0x18919887, - NvAPI_SetGpuTopologies = 0x25201F3D, - NvAPI_SetHUEAngle = 0x0F5A0F22C, - NvAPI_SetHybridMode = 0x0FB22D656, - NvAPI_SetImageSharpeningLevel = 0x3FC9A59C, - NvAPI_SetInfoFrame = 0x69C6F365, - NvAPI_SetInfoFrameState = 0x67EFD887, - NvAPI_SetPVExtName = 0x4FEEB498, - NvAPI_SetPVExtProfile = 0x8354A8F4, - NvAPI_SetTopologyDisplayGPU = 0xF409D5E5, - NvAPI_SetTopologyFocusDisplayAndView = 0x0A8064F9, - NvAPI_SetTVEncoderControls = 0x0CA36A3AB, - NvAPI_SetTVOutputBorderColor = 0x0AED02700, - NvAPI_SetUnderscanConfig = 0x3EFADA1D, - NvAPI_SetVideoState = 0x54FE75A, - NvAPI_Stereo_AppHandShake = 0x8C610BDA, - NvAPI_Stereo_ForceToScreenDepth = 0x2D495758, - NvAPI_Stereo_GetCursorSeparation = 0x72162B35, - NvAPI_Stereo_GetPixelShaderConstantB = 0x0C79333AE, - NvAPI_Stereo_GetPixelShaderConstantF = 0x0D4974572, - NvAPI_Stereo_GetPixelShaderConstantI = 0x0ECD8F8CF, - NvAPI_Stereo_GetStereoCaps = 0x0DFC063B7, - NvAPI_Stereo_GetVertexShaderConstantB = 0x712BAA5B, - NvAPI_Stereo_GetVertexShaderConstantF = 0x622FDC87, - NvAPI_Stereo_GetVertexShaderConstantI = 0x5A60613A, - NvAPI_Stereo_HandShake_Message_Control = 0x315E0EF0, - NvAPI_Stereo_HandShake_Trigger_Activation = 0x0B30CD1A7, - NvAPI_Stereo_Is3DCursorSupported = 0x0D7C9EC09, - NvAPI_Stereo_SetCursorSeparation = 0x0FBC08FC1, - NvAPI_Stereo_SetPixelShaderConstantB = 0x0BA6109EE, - NvAPI_Stereo_SetPixelShaderConstantF = 0x0A9657F32, - NvAPI_Stereo_SetPixelShaderConstantI = 0x912AC28F, - NvAPI_Stereo_SetVertexShaderConstantB = 0x5268716F, - NvAPI_Stereo_SetVertexShaderConstantF = 0x416C07B3, - NvAPI_Stereo_SetVertexShaderConstantI = 0x7923BA0E, - NvAPI_SYS_GetChipSetTopologyStatus = 0x8A50F126, - NvAPI_SYS_GetSliApprovalCookie = 0xB539A26E, - NvAPI_SYS_SetPostOutput = 0xD3A092B1, - NvAPI_SYS_VenturaGetCoolingBudget = 0x0C9D86E33, - NvAPI_SYS_VenturaGetPowerReading = 0x63685979, - NvAPI_SYS_VenturaGetState = 0x0CB7C208D, - NvAPI_SYS_VenturaSetCoolingBudget = 0x85FF5A15, - NvAPI_SYS_VenturaSetState = 0x0CE2E9D9, - NvAPI_TryCustomDisplay = 0x0BF6C1762, - NvAPI_VideoGetStereoInfo = 0x8E1F8CFE, - NvAPI_VideoSetStereoInfo = 0x97063269, - NvAPI_GPU_ClientFanCoolersGetInfo = 0xfb85b01e, - NvAPI_GPU_ClientFanCoolersGetStatus = 0x35aed5e8, - NvAPI_GPU_ClientFanCoolersGetControl = 0x814b209f, - NvAPI_GPU_ClientFanCoolersSetControl = 0xa58971a5, - Unknown_1629A173 = 0x1629a173, // `Unknown(*mut { version = 0x00030038, count, .. })` - Unknown_36E39E6B = 0x36e39e6b, // `Unknown(*mut { version = 0x0002000c, count, ... })` might be handles? - Unknown_B7BCF50D = 0xb7bcf50d, // `Unknown(hGpu, *mut { version = 0x00010008, value })` seen `value = 0x703` - Unknown_F1D2777B = 0xf1d2777b, // `Unknown(hDisplayHandle, *mut hGpu)` maybe? - - #endregion - - NvAPI_Unload = 0xD22BDD7E, - NvAPI_Initialize = 0x150E828 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray.cs b/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray.cs deleted file mode 100644 index 68db6755..00000000 --- a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Helpers.Structures -{ - [StructLayout(LayoutKind.Sequential)] - internal struct ValueTypeArray : IDisposable, IHandle, IEquatable - { - // ReSharper disable once ConvertToAutoProperty - public IntPtr MemoryAddress { get; } - - public static ValueTypeArray Null - { - get => new ValueTypeArray(); - } - - public bool IsNull - { - get => MemoryAddress == IntPtr.Zero; - } - - public ValueTypeArray(IntPtr memoryAddress) - { - MemoryAddress = memoryAddress; - } - - public static ValueTypeArray FromArray(IEnumerable list) - { - var array = list.ToArray(); - - if (array.Length > 0) - { - if (array[0] == null || !array[0].GetType().IsValueType) - { - throw new ArgumentException("Only Value Types are acceptable.", nameof(list)); - } - - var type = array[0].GetType(); - - if (array.Any(item => item.GetType() != type)) - { - throw new ArgumentException("Array should not hold objects of multiple types.", nameof(list)); - } - - return FromArray(array, type); - } - - return Null; - } - - - // ReSharper disable once ExcessiveIndentation - // ReSharper disable once MethodTooLong - public static ValueTypeArray FromArray(IEnumerable list, Type type) - { - var array = list.ToArray(); - - if (array.Length > 0) - { - var typeSize = Marshal.SizeOf(type); - var memoryAddress = Marshal.AllocHGlobal(array.Length * typeSize); - - if (memoryAddress != IntPtr.Zero) - { - var result = new ValueTypeArray(memoryAddress); - - foreach (var item in array) - { - if (type == typeof(int)) - { - Marshal.WriteInt32(memoryAddress, (int) item); - } - else if (type == typeof(uint)) - { - Marshal.WriteInt32(memoryAddress, (int) (uint) item); - } - else if (type == typeof(short)) - { - Marshal.WriteInt16(memoryAddress, (short) item); - } - else if (type == typeof(ushort)) - { - Marshal.WriteInt16(memoryAddress, (short) (ushort) item); - } - else if (type == typeof(long)) - { - Marshal.WriteInt64(memoryAddress, (long) item); - } - else if (type == typeof(ulong)) - { - Marshal.WriteInt64(memoryAddress, (long) (ulong) item); - } - else if (type == typeof(byte)) - { - Marshal.WriteByte(memoryAddress, (byte) item); - } - else if (type == typeof(IntPtr)) - { - Marshal.WriteIntPtr(memoryAddress, (IntPtr) item); - } - else - { - Marshal.StructureToPtr(item, memoryAddress, false); - } - - memoryAddress += typeSize; - } - - return result; - } - } - - return Null; - } - - public bool Equals(ValueTypeArray other) - { - return MemoryAddress.Equals(other.MemoryAddress); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ValueTypeArray array && Equals(array); - } - - public override int GetHashCode() - { - return MemoryAddress.GetHashCode(); - } - - public static bool operator ==(ValueTypeArray left, ValueTypeArray right) - { - return left.Equals(right); - } - - public static bool operator !=(ValueTypeArray left, ValueTypeArray right) - { - return !left.Equals(right); - } - - public static ValueTypeArray FromArray(T[] array) where T : struct - { - return FromArray(array.Cast()); - } - - public T[] ToArray(int count) where T : struct - { - return ToArray(count, typeof(T)); - } - - public T[] ToArray(int count, Type type) - { - return ToArray(0, count, type); - } - - public T[] ToArray(int start, int count) where T : struct - { - return ToArray(start, count, typeof(T)).ToArray(); - } - - public T[] ToArray(int start, int count, Type type) - { - if (IsNull) - { - return null; - } - - return AsEnumerable(start, count, type).ToArray(); - } - - public IEnumerable AsEnumerable(int count) where T : struct - { - return AsEnumerable(count, typeof(T)); - } - - - public IEnumerable AsEnumerable(int count, Type type) - { - return AsEnumerable(0, count, type); - } - - public IEnumerable AsEnumerable(int start, int count) where T : struct - { - return AsEnumerable(start, count, typeof(T)); - } - - // ReSharper disable once ExcessiveIndentation - // ReSharper disable once MethodTooLong - public IEnumerable AsEnumerable(int start, int count, Type type) - { - if (!IsNull) - { - if (!type.IsValueType) - { - throw new ArgumentException("Only Value Types are acceptable.", nameof(type)); - } - - var typeSize = Marshal.SizeOf(type); - var address = MemoryAddress + start * typeSize; - - for (var i = 0; i < count; i++) - { - if (type == typeof(int)) - { - yield return (T) (object) Marshal.ReadInt32(address); - } - else if (type == typeof(uint)) - { - yield return (T) (object) (uint) Marshal.ReadInt32(address); - } - else if (type == typeof(short)) - { - yield return (T) (object) Marshal.ReadInt16(address); - } - else if (type == typeof(ushort)) - { - yield return (T) (object) (ushort) Marshal.ReadInt16(address); - } - else if (type == typeof(long)) - { - yield return (T) (object) Marshal.ReadInt64(address); - } - else if (type == typeof(ulong)) - { - yield return (T) (object) (ulong) Marshal.ReadInt64(address); - } - else if (type == typeof(byte)) - { - yield return (T) (object) Marshal.ReadByte(address); - } - else if (type == typeof(IntPtr)) - { - yield return (T) (object) Marshal.ReadIntPtr(address); - } - else - { - yield return (T) Marshal.PtrToStructure(address, type); - } - - address += typeSize; - } - } - } - - - public void Dispose() - { - if (!IsNull) - { - Marshal.FreeHGlobal(MemoryAddress); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray`1.cs b/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray`1.cs deleted file mode 100644 index 45568123..00000000 --- a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeArray`1.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Helpers.Structures -{ - [StructLayout(LayoutKind.Sequential)] - internal struct ValueTypeArray : IDisposable, IHandle, IEquatable> where T : struct - { - private ValueTypeArray underlyingArray; - - public IntPtr MemoryAddress - { - get => underlyingArray.MemoryAddress; - } - - public static ValueTypeArray Null - { - get => new ValueTypeArray(); - } - - public bool IsNull - { - get => underlyingArray.IsNull; - } - - public ValueTypeArray(IntPtr memoryAddress) - { - underlyingArray = new ValueTypeArray(memoryAddress); - } - - private ValueTypeArray(ValueTypeArray underlyingArray) - { - this.underlyingArray = underlyingArray; - } - - public static ValueTypeArray FromArray(T[] array) - { - return new ValueTypeArray(ValueTypeArray.FromArray(array)); - } - - public static ValueTypeArray FromArray(IEnumerable list, Type type) - { - return new ValueTypeArray(ValueTypeArray.FromArray(list.Cast(), type)); - } - - public bool Equals(ValueTypeArray other) - { - return underlyingArray.Equals(other.underlyingArray); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ValueTypeArray array && Equals(array); - } - - public override int GetHashCode() - { - // ReSharper disable once NonReadonlyMemberInGetHashCode - return underlyingArray.GetHashCode(); - } - - public static bool operator ==(ValueTypeArray left, ValueTypeArray right) - { - return left.Equals(right); - } - - public static bool operator !=(ValueTypeArray left, ValueTypeArray right) - { - return !left.Equals(right); - } - - public T[] ToArray(int count) - { - return underlyingArray.ToArray(count, typeof(T)); - } - - public T[] ToArray(int count, Type type) - { - return underlyingArray.ToArray(0, count, type); - } - - public T[] ToArray(int start, int count) - { - return underlyingArray.ToArray(start, count, typeof(T)).ToArray(); - } - - public T[] ToArray(int start, int count, Type type) - { - return underlyingArray.ToArray(start, count, type); - } - - public IEnumerable AsEnumerable(int count) - { - return underlyingArray.AsEnumerable(count, typeof(T)); - } - - public IEnumerable AsEnumerable(int count, Type type) - { - return underlyingArray.AsEnumerable(0, count, type); - } - - public IEnumerable AsEnumerable(int start, int count) - { - return underlyingArray.AsEnumerable(start, count, typeof(T)); - } - - public IEnumerable AsEnumerable(int start, int count, Type type) - { - return underlyingArray.AsEnumerable(start, count, type); - } - - public void Dispose() - { - if (!IsNull) - { - underlyingArray.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference.cs b/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference.cs deleted file mode 100644 index 7d983b57..00000000 --- a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Helpers.Structures -{ - [StructLayout(LayoutKind.Sequential)] - internal struct ValueTypeReference : IDisposable, IHandle, IEquatable - { - // ReSharper disable once ConvertToAutoProperty - public IntPtr MemoryAddress { get; } - - public static ValueTypeReference Null - { - get => new ValueTypeReference(); - } - - public bool IsNull - { - get => MemoryAddress == IntPtr.Zero; - } - - public ValueTypeReference(IntPtr memoryAddress) - { - MemoryAddress = memoryAddress; - } - - public static ValueTypeReference FromValueType(T valueType) where T : struct - { - return FromValueType(valueType, typeof(T)); - } - - public static ValueTypeReference FromValueType(object valueType, Type type) - { - if (!type.IsValueType) - { - throw new ArgumentException("Only Value Types are acceptable.", nameof(type)); - } - - var memoryAddress = Marshal.AllocHGlobal(Marshal.SizeOf(type)); - - if (memoryAddress != IntPtr.Zero) - { - var result = new ValueTypeReference(memoryAddress); - Marshal.StructureToPtr(valueType, memoryAddress, false); - - return result; - } - - return Null; - } - - public bool Equals(ValueTypeReference other) - { - return MemoryAddress.Equals(other.MemoryAddress); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ValueTypeReference reference && Equals(reference); - } - - public override int GetHashCode() - { - return MemoryAddress.GetHashCode(); - } - - public static bool operator ==(ValueTypeReference left, ValueTypeReference right) - { - return left.Equals(right); - } - - public static bool operator !=(ValueTypeReference left, ValueTypeReference right) - { - return !left.Equals(right); - } - - public T ToValueType(Type type) - { - if (MemoryAddress == IntPtr.Zero) - { - return default(T); - } - - if (!type.IsValueType) - { - throw new ArgumentException("Only Value Types are acceptable.", nameof(type)); - } - - return (T) Marshal.PtrToStructure(MemoryAddress, type); - } - - public T? ToValueType() where T : struct - { - if (IsNull) - { - return null; - } - - return ToValueType(typeof(T)); - } - - public void Dispose() - { - if (!IsNull) - { - Marshal.FreeHGlobal(MemoryAddress); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference`1.cs b/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference`1.cs deleted file mode 100644 index 3fd8e667..00000000 --- a/app/NvAPIWrapper/Native/Helpers/Structures/ValueTypeReference`1.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Helpers.Structures -{ - [StructLayout(LayoutKind.Sequential)] - internal struct ValueTypeReference : IDisposable, IHandle, IEquatable> where T : struct - { - private ValueTypeReference underlyingReference; - - public IntPtr MemoryAddress - { - get => underlyingReference.MemoryAddress; - } - - public static ValueTypeReference Null - { - get => new ValueTypeReference(); - } - - public bool IsNull - { - get => underlyingReference.IsNull; - } - - public ValueTypeReference(IntPtr memoryAddress) - { - underlyingReference = new ValueTypeReference(memoryAddress); - } - - private ValueTypeReference(ValueTypeReference underlyingReference) - { - this.underlyingReference = underlyingReference; - } - - public static ValueTypeReference FromValueType(T valueType) - { - return new ValueTypeReference(ValueTypeReference.FromValueType(valueType)); - } - - public static ValueTypeReference FromValueType(object valueType, Type type) - { - return new ValueTypeReference(ValueTypeReference.FromValueType(valueType, type)); - } - - public bool Equals(ValueTypeReference other) - { - return underlyingReference.Equals(other.underlyingReference); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is ValueTypeReference reference && Equals(reference); - } - - public override int GetHashCode() - { - // ReSharper disable once NonReadonlyMemberInGetHashCode - return underlyingReference.GetHashCode(); - } - - public static bool operator ==(ValueTypeReference left, ValueTypeReference right) - { - return left.Equals(right); - } - - public static bool operator !=(ValueTypeReference left, ValueTypeReference right) - { - return !left.Equals(right); - } - - public T ToValueType(Type type) - { - return underlyingReference.ToValueType(type); - } - - public T? ToValueType() - { - return underlyingReference.ToValueType(); - } - - public void Dispose() - { - if (!IsNull) - { - underlyingReference.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/DRS/IDRSApplication.cs b/app/NvAPIWrapper/Native/Interfaces/DRS/IDRSApplication.cs deleted file mode 100644 index db32a153..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/DRS/IDRSApplication.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.DRS -{ - /// - /// Represents an application rule registered in a profile - /// - public interface IDRSApplication - { - /// - /// Gets the application name - /// - string ApplicationName { get; } - - /// - /// Gets the application friendly name - /// - string FriendlyName { get; } - - /// - /// Gets a boolean value indicating if this application is predefined as part of NVIDIA driver - /// - bool IsPredefined { get; } - - /// - /// Gets the application launcher name. - /// - string LauncherName { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IColorData.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IColorData.cs deleted file mode 100644 index 4f2821d5..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IColorData.cs +++ /dev/null @@ -1,40 +0,0 @@ -using NvAPIWrapper.Native.Display; - -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Contains data corresponding to color information - /// - public interface IColorData - { - /// - /// Gets the color data color depth - /// - ColorDataDepth? ColorDepth { get; } - - /// - /// Gets the color data dynamic range - /// - ColorDataDynamicRange? DynamicRange { get; } - - /// - /// Gets the color data color format - /// - ColorDataFormat ColorFormat { get; } - - /// - /// Gets the color data color space - /// - ColorDataColorimetry Colorimetry { get; } - - /// - /// Gets the color data selection policy - /// - ColorDataSelectionPolicy? SelectionPolicy { get; } - - /// - /// Gets the color data desktop color depth - /// - ColorDataDesktopDepth? DesktopColorDepth { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayColorData.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayColorData.cs deleted file mode 100644 index 9ff47b2b..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayColorData.cs +++ /dev/null @@ -1,30 +0,0 @@ -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Holds information regarding a display color space configurations - /// - public interface IDisplayColorData - { - /// - /// Gets the first primary color space coordinate (e.g. Red for RGB) [(0.0, 0.0)-(1.0, 1.0)] - /// - ColorDataColorCoordinate FirstColorCoordinate { get; } - - /// - /// Gets the second primary color space coordinate (e.g. Green for RGB) [(0.0, 0.0)-(1.0, 1.0)] - /// - ColorDataColorCoordinate SecondColorCoordinate { get; } - - /// - /// Gets the third primary color space coordinate (e.g. Blue for RGB) [(0.0, 0.0)-(1.0, 1.0)] - /// - ColorDataColorCoordinate ThirdColorCoordinate { get; } - - /// - /// Gets the white color space coordinate [(0.0, 0.0)-(1.0, 1.0)] - /// - ColorDataColorCoordinate WhiteColorCoordinate { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayDVCInfo.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayDVCInfo.cs deleted file mode 100644 index 39a08b1a..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IDisplayDVCInfo.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Holds the Digital Vibrance Control information regarding the saturation level. - /// - public interface IDisplayDVCInfo - { - /// - /// Gets the current saturation level - /// - int CurrentLevel { get; } - - /// - /// Gets the default saturation level - /// - int DefaultLevel { get; } - - /// - /// Gets the maximum valid saturation level - /// - int MaximumLevel { get; } - - /// - /// Gets the minimum valid saturation level - /// - int MinimumLevel { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IHDMISupportInfo.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IHDMISupportInfo.cs deleted file mode 100644 index aa97a850..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IHDMISupportInfo.cs +++ /dev/null @@ -1,74 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Contains information about the HDMI capabilities of the GPU, output and the display device attached - /// - public interface IHDMISupportInfo - { - /// - /// Gets the display's EDID 861 Extension Revision - /// - uint EDID861ExtensionRevision { get; } - - /// - /// Gets a boolean value indicating that the GPU is capable of HDMI output - /// - bool IsGPUCapableOfHDMIOutput { get; } - - /// - /// Gets a boolean value indicating that the display is connected via HDMI - /// - bool IsHDMIMonitor { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of Adobe RGB if such data is available; - /// otherwise null - /// - bool? IsMonitorCapableOfAdobeRGB { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of Adobe YCC601 if such data is available; - /// otherwise null - /// - bool? IsMonitorCapableOfAdobeYCC601 { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of basic audio - /// - bool IsMonitorCapableOfBasicAudio { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of sYCC601 if such data is available; - /// otherwise null - /// - bool? IsMonitorCapableOfsYCC601 { get; } - - - /// - /// Gets a boolean value indicating that the connected display is capable of underscan - /// - bool IsMonitorCapableOfUnderscan { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of xvYCC601 - /// - // ReSharper disable once IdentifierTypo - bool IsMonitorCapableOfxvYCC601 { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of xvYCC709 - /// - // ReSharper disable once IdentifierTypo - bool IsMonitorCapableOfxvYCC709 { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of YCbCr422 - /// - bool IsMonitorCapableOfYCbCr422 { get; } - - /// - /// Gets a boolean value indicating that the connected display is capable of YCbCr444 - /// - bool IsMonitorCapableOfYCbCr444 { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IHDRColorData.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IHDRColorData.cs deleted file mode 100644 index 5ce244f7..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IHDRColorData.cs +++ /dev/null @@ -1,37 +0,0 @@ -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Contains information regarding HDR color data - /// - public interface IHDRColorData - { - /// - /// Gets the HDR color depth if available; otherwise null - /// For Dolby Vision only, should and will be ignored if HDR is on - /// - ColorDataDepth? ColorDepth { get; } - - /// - /// Gets the HDR color format if available; otherwise null - /// - ColorDataFormat? ColorFormat { get; } - - /// - /// Gets the HDR dynamic range if available; otherwise null - /// - ColorDataDynamicRange? DynamicRange { get; } - - /// - /// Gets the HDR mode - /// - ColorDataHDRMode HDRMode { get; } - - /// - /// Gets the color space coordinates - /// - MasteringDisplayColorData MasteringDisplayData { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IPathInfo.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IPathInfo.cs deleted file mode 100644 index 13fa7f9a..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IPathInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Interface for all PathInfo structures - /// - public interface IPathInfo : IDisposable - { - /// - /// Identifies sourceId used by Windows CCD. This can be optionally set. - /// - uint SourceId { get; } - - /// - /// Contains information about the source mode - /// - SourceModeInfo SourceModeInfo { get; } - - /// - /// Contains information about path targets - /// - IEnumerable TargetsInfo { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IPathTargetInfo.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IPathTargetInfo.cs deleted file mode 100644 index 02788428..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IPathTargetInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NvAPIWrapper.Native.Display.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Display -{ - /// - /// Interface for all PathTargetInfo structures - /// - public interface IPathTargetInfo - { - /// - /// Contains extra information. NULL for Non-NVIDIA Display. - /// - PathAdvancedTargetInfo? Details { get; } - - /// - /// Display identification - /// - uint DisplayId { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Display/IScanOutIntensityData.cs b/app/NvAPIWrapper/Native/Interfaces/Display/IScanOutIntensityData.cs deleted file mode 100644 index 3aae9c21..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Display/IScanOutIntensityData.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace NvAPIWrapper.Native.Display.Structures -{ - /// - /// Contains information regarding the scan-out intensity data - /// - public interface IScanOutIntensity { - - /// - /// Gets the array of floating values building an intensity RGB texture - /// - float[] BlendingTexture { get; } - - /// - /// Gets the height of the input texture - /// - uint Height { get; } - - - /// - /// Gets the width of the input texture - /// - uint Width { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IClockFrequencies.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IClockFrequencies.cs deleted file mode 100644 index fe4d43da..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IClockFrequencies.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Interface for all ClockFrequencies structures - /// - public interface IClockFrequencies - { - /// - /// Gets all valid clocks - /// - IReadOnlyDictionary Clocks { get; } - - /// - /// Gets the type of clock frequencies provided with this object - /// - ClockType ClockType { get; } - - /// - /// Gets graphics engine clock - /// - ClockDomainInfo GraphicsClock { get; } - - /// - /// Gets memory decoding clock - /// - ClockDomainInfo MemoryClock { get; } - - /// - /// Gets processor clock - /// - ClockDomainInfo ProcessorClock { get; } - - /// - /// Gets video decoding clock - /// - ClockDomainInfo VideoDecodingClock { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayDriverMemoryInfo.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayDriverMemoryInfo.cs deleted file mode 100644 index f4dbea23..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayDriverMemoryInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Interface for all DisplayDriverMemoryInfo structures - /// - public interface IDisplayDriverMemoryInfo - { - /// - /// Size(in kb) of the available physical frame buffer for allocating video memory surfaces. - /// - uint AvailableDedicatedVideoMemoryInkB { get; } - - /// - /// Size(in kb) of the current available physical frame buffer for allocating video memory surfaces. - /// - uint CurrentAvailableDedicatedVideoMemoryInkB { get; } - - /// - /// Size(in kb) of the physical frame buffer. - /// - uint DedicatedVideoMemoryInkB { get; } - - /// - /// Size(in kb) of shared system memory that driver is allowed to commit for surfaces across all allocations. - /// - uint SharedSystemMemoryInkB { get; } - - /// - /// Size(in kb) of system memory the driver allocates at load time. - /// - uint SystemVideoMemoryInkB { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayIds.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayIds.cs deleted file mode 100644 index 4e0c2e48..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IDisplayIds.cs +++ /dev/null @@ -1,65 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Interface for all DisplayIds structures - /// - public interface IDisplayIds - { - /// - /// Gets connection type. This is reserved for future use and clients should not rely on this information. Instead get - /// the GPU connector type from NvAPI_GPU_GetConnectorInfo/NvAPI_GPU_GetConnectorInfoEx - /// - MonitorConnectionType ConnectionType { get; } - - /// - /// Gets a unique identifier for each device - /// - uint DisplayId { get; } - - /// - /// Indicates if the display is being actively driven - /// - bool IsActive { get; } - - /// - /// Indicates if the display is the representative display - /// - bool IsCluster { get; } - - /// - /// Indicates if the display is connected - /// - bool IsConnected { get; } - - /// - /// Indicates if the display is part of MST topology and it's a dynamic - /// - bool IsDynamic { get; } - - /// - /// Indicates if the display identification belongs to a multi stream enabled connector (root node). Note that when - /// multi stream is enabled and a single multi stream capable monitor is connected to it, the monitor will share the - /// display id with the RootNode. - /// When there is more than one monitor connected in a multi stream topology, then the root node will have a separate - /// displayId. - /// - bool IsMultiStreamRootNode { get; } - - /// - /// Indicates if the display is reported to the OS - /// - bool IsOSVisible { get; } - - /// - /// Indicates if the display is a physically connected display; Valid only when IsConnected is true - /// - bool IsPhysicallyConnected { get; } - - /// - /// Indicates if the display is wireless - /// - bool IsWFD { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IEDID.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IEDID.cs deleted file mode 100644 index 3dfac158..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IEDID.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Interface for all EDID structures - /// - public interface IEDID - { - /// - /// Gets whole or a part of the EDID data - /// - byte[] Data { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/II2CInfo.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/II2CInfo.cs deleted file mode 100644 index aaf7a093..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/II2CInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Contains an I2C packet transmitted or to be transmitted - /// - public interface II2CInfo - { - /// - /// Gets the payload data - /// - byte[] Data { get; } - - /// - /// Gets the device I2C slave address - /// - byte DeviceAddress { get; } - - /// - /// Gets a boolean value indicating that this instance contents information about a read operation - /// - bool IsReadOperation { get; } - - /// - /// Gets the target display output mask - /// - OutputId OutputMask { get; } - - /// - /// Gets the port id on which device is connected - /// - byte? PortId { get; } - - /// - /// Gets the target I2C register address - /// - byte[] RegisterAddress { get; } - - /// - /// Gets the target speed of the transaction in kHz - /// - I2CSpeed Speed { get; } - - /// - /// Gets a boolean value indicating that the DDC port should be used instead of the communication port - /// - bool UseDDCPort { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState.cs deleted file mode 100644 index 233bb9c0..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState.cs +++ /dev/null @@ -1,30 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding a performance state - /// - public interface IPerformanceState - { - /// - /// Gets a boolean value indicating if this performance state is overclockable - /// - bool IsOverclockable { get; } - - /// - /// Gets a boolean value indicating if this performance state is currently overclocked - /// - bool IsOverclocked { get; } - - /// - /// Gets a boolean value indicating if this performance state is limited to use PCIE generation 1 or PCIE generation 2 - /// - bool IsPCIELimited { get; } - - /// - /// Gets the performance state identification - /// - PerformanceStateId StateId { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState20.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState20.cs deleted file mode 100644 index f98549eb..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceState20.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding a performance state v2 - /// - public interface IPerformanceState20 - { - /// - /// Gets a boolean value indicating if this performance state is editable - /// - bool IsEditable { get; } - - /// - /// Gets the performance state identification - /// - PerformanceStateId StateId { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentFrequencyRange.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentFrequencyRange.cs deleted file mode 100644 index 464d55da..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentFrequencyRange.cs +++ /dev/null @@ -1,36 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding the frequency range of a clock domain as well as the dependent voltage domain and the - /// range of the voltage - /// - public interface IPerformanceStates20ClockDependentFrequencyRange - { - /// - /// Gets the maximum clock frequency in kHz - /// - uint MaximumFrequencyInkHz { get; } - - /// - /// Gets the dependent voltage domain's maximum voltage in uV - /// - uint MaximumVoltageInMicroVolt { get; } - - /// - /// Gets the minimum clock frequency in kHz - /// - uint MinimumFrequencyInkHz { get; } - - /// - /// Gets the dependent voltage domain's minimum voltage in uV - /// - uint MinimumVoltageInMicroVolt { get; } - - /// - /// Gets the dependent voltage domain identification - /// - PerformanceVoltageDomain VoltageDomainId { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentSingleFrequency.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentSingleFrequency.cs deleted file mode 100644 index 7db07922..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockDependentSingleFrequency.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding the clock frequency of a fixed frequency clock domain - /// - public interface IPerformanceStates20ClockDependentSingleFrequency - { - /// - /// Gets the clock frequency of a clock domain in kHz - /// - uint FrequencyInkHz { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockEntry.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockEntry.cs deleted file mode 100644 index a6119aaf..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20ClockEntry.cs +++ /dev/null @@ -1,42 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding a clock domain of a performance states - /// - public interface IPerformanceStates20ClockEntry - { - /// - /// Gets the type of clock frequency - /// - PerformanceStates20ClockType ClockType { get; } - - /// - /// Gets the domain identification - /// - PublicClockDomain DomainId { get; } - - /// - /// Gets the current base frequency delta value and the range for a valid delta value - /// - PerformanceStates20ParameterDelta FrequencyDeltaInkHz { get; } - - /// - /// Gets the fixed frequency of the clock - /// - IPerformanceStates20ClockDependentFrequencyRange FrequencyRange { get; } - - - /// - /// Gets a boolean value indicating if this clock is editable - /// - bool IsEditable { get; } - - /// - /// Gets the range of clock frequency and related voltage information if present - /// - IPerformanceStates20ClockDependentSingleFrequency SingleFrequency { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20Info.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20Info.cs deleted file mode 100644 index e18a01d2..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20Info.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding the valid power states and their clock and voltage settings as well as general - /// over-volting settings - /// - public interface IPerformanceStates20Info - { - /// - /// Gets a dictionary for valid power states and their clock frequencies - /// - IDictionary Clocks { get; } - - /// - /// Gets the list of general over-volting settings - /// - IPerformanceStates20VoltageEntry[] GeneralVoltages { get; } - - /// - /// Gets a boolean value indicating if performance states are editable - /// - bool IsEditable { get; } - - /// - /// Gets an array of valid power states for the GPU - /// - IPerformanceState20[] PerformanceStates { get; } - - /// - /// Gets a dictionary for valid power states and their voltage settings - /// - IReadOnlyDictionary Voltages { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20VoltageEntry.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20VoltageEntry.cs deleted file mode 100644 index b4912e3a..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStates20VoltageEntry.cs +++ /dev/null @@ -1,31 +0,0 @@ -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding the voltage of a voltage domain - /// - public interface IPerformanceStates20VoltageEntry - { - /// - /// Gets the voltage domain identification - /// - PerformanceVoltageDomain DomainId { get; } - - /// - /// Gets a boolean value indicating this voltage domain is editable - /// - bool IsEditable { get; } - - /// - /// Gets the base voltage delta and the range of valid values for the delta value - /// - PerformanceStates20ParameterDelta ValueDeltaInMicroVolt { get; } - - /// - /// Gets the current value of this voltage domain in uV - /// - uint ValueInMicroVolt { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesClock.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesClock.cs deleted file mode 100644 index 1d41828f..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesClock.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding a clock domain of a performance state - /// - public interface IPerformanceStatesClock - { - /// - /// Gets the clock domain identification - /// - PublicClockDomain DomainId { get; } - - /// - /// Gets the clock frequency in kHz - /// - uint Frequency { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesInfo.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesInfo.cs deleted file mode 100644 index 4fd6e8d6..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesInfo.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding performance states status of a GPU - /// - public interface IPerformanceStatesInfo - { - /// - /// Gets a boolean value indicating if the device is capable of dynamic performance state switching - /// - bool IsCapableOfDynamicPerformance { get; } - - /// - /// Gets a boolean value indicating if the dynamic performance state switching is enable - /// - bool IsDynamicPerformanceEnable { get; } - - /// - /// Gets a boolean value indicating if the performance monitoring is enable - /// - bool IsPerformanceMonitorEnable { get; } - - /// - /// Gets an array of valid and available performance states information - /// - IPerformanceState[] PerformanceStates { get; } - - /// - /// Gets a dictionary of valid and available performance states and their clock information as an array - /// - IReadOnlyDictionary PerformanceStatesClocks { get; } - - /// - /// Gets a dictionary of valid and available performance states and their voltage information as an array - /// - IReadOnlyDictionary PerformanceStatesVoltages { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesVoltage.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesVoltage.cs deleted file mode 100644 index 28bff241..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IPerformanceStatesVoltage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds information regarding a voltage domain of a performance state - /// - public interface IPerformanceStatesVoltage - { - /// - /// Gets the voltage domain identification - /// - PerformanceVoltageDomain DomainId { get; } - - /// - /// Gets the voltage in mV - /// - uint Value { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSensor.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSensor.cs deleted file mode 100644 index 8279633a..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSensor.cs +++ /dev/null @@ -1,35 +0,0 @@ -using NvAPIWrapper.Native.GPU; - -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Provides information about a single thermal sensor - /// - public interface IThermalSensor - { - /// - /// Internal, ADM1032, MAX6649... - /// - ThermalController Controller { get; } - - /// - /// Current temperature value of the thermal sensor in degree Celsius - /// - int CurrentTemperature { get; } - - /// - /// Maximum default temperature value of the thermal sensor in degree Celsius - /// - int DefaultMaximumTemperature { get; } - - /// - /// Minimum default temperature value of the thermal sensor in degree Celsius - /// - int DefaultMinimumTemperature { get; } - - /// - /// Thermal sensor targeted - GPU, memory, chipset, power supply, Visual Computing Device, etc - /// - ThermalSettingsTarget Target { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSettings.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSettings.cs deleted file mode 100644 index 0fa64f9f..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IThermalSettings.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - /// - /// Holds a list of thermal sensors - /// - public interface IThermalSettings - { - /// - /// Gets a list of requested thermal sensor information - /// - IThermalSensor[] Sensors { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationDomainInfo.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationDomainInfo.cs deleted file mode 100644 index e3e161ca..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationDomainInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.GPU -{ - - /// - /// Holds information about a utilization domain - /// - public interface IUtilizationDomainInfo - { - /// - /// Gets a boolean value that indicates if this utilization domain is present on this GPU. - /// - bool IsPresent { get; } - - /// - /// Gets the percentage of time where the domain is considered busy in the last 1 second interval. - /// - uint Percentage { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationStatus.cs b/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationStatus.cs deleted file mode 100644 index a5cc333c..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/GPU/IUtilizationStatus.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.Interfaces.GPU; - -namespace NvAPIWrapper.Native.GPU.Structures -{ - /// - /// Holds information about the GPU utilization domains - /// - public interface IUtilizationStatus - { - - /// - /// Gets the Bus interface (BUS) utilization - /// - IUtilizationDomainInfo BusInterface { get; } - /// - /// Gets all valid utilization domains and information - /// - Dictionary Domains { get; } - - /// - /// Gets the frame buffer (FB) utilization - /// - IUtilizationDomainInfo FrameBuffer { get; } - - /// - /// Gets the graphic engine (GPU) utilization - /// - IUtilizationDomainInfo GPU { get; } - - - /// - /// Gets the Video engine (VID) utilization - /// - IUtilizationDomainInfo VideoEngine { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/General/IChipsetInfo.cs b/app/NvAPIWrapper/Native/Interfaces/General/IChipsetInfo.cs deleted file mode 100644 index cb17efa3..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/General/IChipsetInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using NvAPIWrapper.Native.General; - -namespace NvAPIWrapper.Native.Interfaces.General -{ - /// - /// Interface for all ChipsetInfo structures - /// - public interface IChipsetInfo - { - /// - /// Chipset device name - /// - string ChipsetName { get; } - - /// - /// Chipset device identification - /// - int DeviceId { get; } - - /// - /// Chipset information flags - obsolete - /// - ChipsetInfoFlag Flags { get; } - - /// - /// Chipset vendor identification - /// - int VendorId { get; } - - /// - /// Chipset vendor name - /// - string VendorName { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/IAllocatable.cs b/app/NvAPIWrapper/Native/Interfaces/IAllocatable.cs deleted file mode 100644 index 7655d403..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/IAllocatable.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Interfaces -{ - /// - /// Marker interface for all types that should be allocated before passing to the managed code - /// - internal interface IAllocatable : IInitializable, IDisposable - { - void Allocate(); - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/IHandle.cs b/app/NvAPIWrapper/Native/Interfaces/IHandle.cs deleted file mode 100644 index 655a3a93..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/IHandle.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Interfaces -{ - /// - /// Interface for all pointer based handles - /// - public interface IHandle - { - /// - /// Returns true if the handle is null and not pointing to a valid location in the memory - /// - bool IsNull { get; } - - /// - /// Gets the address of the handle in the memory - /// - IntPtr MemoryAddress { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/IInitializable.cs b/app/NvAPIWrapper/Native/Interfaces/IInitializable.cs deleted file mode 100644 index d526abae..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/IInitializable.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces -{ - /// - /// Marker interface for all types that should be filled with information before passing to un-managed code - /// - internal interface IInitializable - { - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IDisplaySettings.cs b/app/NvAPIWrapper/Native/Interfaces/Mosaic/IDisplaySettings.cs deleted file mode 100644 index e6c61c2c..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IDisplaySettings.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace NvAPIWrapper.Native.Interfaces.Mosaic -{ - /// - /// Interface for all DisplaySettings structures - /// - public interface IDisplaySettings - { - /// - /// Bits per pixel - /// - int BitsPerPixel { get; } - - /// - /// Display frequency - /// - int Frequency { get; } - - /// - /// Display frequency in x1k - /// - uint FrequencyInMillihertz { get; } - - /// - /// Per-display height - /// - int Height { get; } - - /// - /// Per-display width - /// - int Width { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopology.cs b/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopology.cs deleted file mode 100644 index cad2c6b4..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopology.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.Mosaic.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Mosaic -{ - /// - /// Interface for all GridTopology structures - /// - public interface IGridTopology - { - /// - /// Enable SLI acceleration on the primary display while in single-wide mode (For Immersive Gaming only). Will not be - /// persisted. Value undefined on get. - /// - bool AcceleratePrimaryDisplay { get; } - - /// - /// When enabling and doing the mode-set, do we switch to the bezel-corrected resolution - /// - bool ApplyWithBezelCorrectedResolution { get; } - - /// - /// Enable as Base Mosaic (Panoramic) instead of Mosaic SLI (for NVS and Quadro-boards only) - /// - bool BaseMosaicPanoramic { get; } - - /// - /// Number of columns - /// - int Columns { get; } - - /// - /// Topology displays; Displays are done as [(row * columns) + column] - /// - IEnumerable Displays { get; } - - /// - /// Display settings - /// - DisplaySettingsV1 DisplaySettings { get; } - - /// - /// If necessary, reloading the driver is permitted (for Vista and above only). Will not be persisted. Value undefined - /// on get. - /// - bool DriverReloadAllowed { get; } - - /// - /// Enable as immersive gaming instead of Mosaic SLI (for Quadro-boards only) - /// - bool ImmersiveGaming { get; } - - /// - /// Number of rows - /// - int Rows { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopologyDisplay.cs b/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopologyDisplay.cs deleted file mode 100644 index 7add3e21..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Mosaic/IGridTopologyDisplay.cs +++ /dev/null @@ -1,42 +0,0 @@ -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Mosaic; - -namespace NvAPIWrapper.Native.Interfaces.Mosaic -{ - /// - /// Interface for all GridTopologyDisplay structures - /// - public interface IGridTopologyDisplay - { - /// - /// Gets the clone group identification; Reserved, must be 0 - /// - uint CloneGroup { get; } - - /// - /// Gets the display identification - /// - uint DisplayId { get; } - - /// - /// Gets the horizontal overlap (+overlap, -gap) - /// - int OverlapX { get; } - - /// - /// Gets the vertical overlap (+overlap, -gap) - /// - int OverlapY { get; } - - - /// - /// Gets the type of display pixel shift - /// - PixelShiftType PixelShiftType { get; } - - /// - /// Gets the rotation of display - /// - Rotate Rotation { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Interfaces/Mosaic/ISupportedTopologiesInfo.cs b/app/NvAPIWrapper/Native/Interfaces/Mosaic/ISupportedTopologiesInfo.cs deleted file mode 100644 index 6bc92fab..00000000 --- a/app/NvAPIWrapper/Native/Interfaces/Mosaic/ISupportedTopologiesInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using NvAPIWrapper.Native.Mosaic.Structures; - -namespace NvAPIWrapper.Native.Interfaces.Mosaic -{ - /// - /// Interface for all SupportedTopologiesInfo structures - /// - public interface ISupportedTopologiesInfo - { - /// - /// List of per display settings possible - /// - IEnumerable DisplaySettings { get; } - - /// - /// List of supported topologies with only brief details - /// - IEnumerable TopologyBriefs { get; } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/DisplayCapacityProblem.cs b/app/NvAPIWrapper/Native/Mosaic/DisplayCapacityProblem.cs deleted file mode 100644 index 21b9fa04..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/DisplayCapacityProblem.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// Possible display problems in a topology validation process - /// - [Flags] - public enum DisplayCapacityProblem : uint - { - /// - /// No problem - /// - NoProblem = 0, - - /// - /// Display is connected to the wrong GPU - /// - DisplayOnInvalidGPU = 1, - - /// - /// Display is connected to the wrong connector - /// - DisplayOnWrongConnector = 2, - - /// - /// Timing configuration is missing - /// - NoCommonTimings = 4, - - /// - /// EDID information is missing - /// - NoEDIDAvailable = 8, - - /// - /// Output type combination is not valid - /// - MismatchedOutputType = 16, - - /// - /// There is no display connected - /// - NoDisplayConnected = 32, - - /// - /// GPU is missing - /// - NoGPUTopology = 64, - - /// - /// Not supported - /// - NotSupported = 128, - - /// - /// SLI Bridge is missing - /// - NoSLIBridge = 256, - - /// - /// ECC is enable - /// - ECCEnabled = 512, - - /// - /// Topology is not supported by GPU - /// - GPUTopologyNotSupported = 1024 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/DisplayTopologyWarning.cs b/app/NvAPIWrapper/Native/Mosaic/DisplayTopologyWarning.cs deleted file mode 100644 index a9d6e15e..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/DisplayTopologyWarning.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// Possible display problems in a topology validation process - /// - [Flags] - public enum DisplayTopologyWarning : uint - { - /// - /// No warning - /// - NoWarning = 0, - - /// - /// Display position is problematic - /// - DisplayPosition = 1, - - /// - /// Driver reload is required for this changes - /// - DriverReloadRequired = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/PixelShiftType.cs b/app/NvAPIWrapper/Native/Mosaic/PixelShiftType.cs deleted file mode 100644 index 51f383e8..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/PixelShiftType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// Possible pixel shift types for a display - /// - public enum PixelShiftType - { - /// - /// No pixel shift will be applied to this display. - /// - NoPixelShift = 0, - - /// - /// This display will be used to scan-out top left pixels in 2x2 PixelShift configuration - /// - TopLeft2X2Pixels = 1, - - /// - /// This display will be used to scan-out bottom right pixels in 2x2 PixelShift configuration - /// - BottomRight2X2Pixels = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/SetDisplayTopologyFlag.cs b/app/NvAPIWrapper/Native/Mosaic/SetDisplayTopologyFlag.cs deleted file mode 100644 index 18110f1d..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/SetDisplayTopologyFlag.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// Possible flags for setting a display topology - /// - [Flags] - public enum SetDisplayTopologyFlag : uint - { - /// - /// No special flag - /// - NoFlag = 0, - - /// - /// Do not change the current GPU topology. If the NO_DRIVER_RELOAD bit is not specified, then it may still require a - /// driver reload. - /// - CurrentGPUTopology = 1, - - /// - /// Do not allow a driver reload. That is, stick with the same master GPU as well as the same SLI configuration. - /// - NoDriverReload = 2, - - /// - /// When choosing a GPU topology, choose the topology with the best performance. - /// Without this flag, it will choose the topology that uses the smallest number of GPUs. - /// - MaximizePerformance = 4, - - /// - /// Do not return an error if no configuration will work with all of the grids. - /// - AllowInvalid = 8 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV1.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV1.cs deleted file mode 100644 index 7d93f6c3..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV1.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds a display setting - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DisplaySettingsV1 : IDisplaySettings, - IInitializable, - IEquatable, - IEquatable - { - internal StructureVersion _Version; - internal readonly uint _Width; - internal readonly uint _Height; - internal readonly uint _BitsPerPixel; - internal readonly uint _Frequency; - - /// - /// Creates a new DisplaySettingsV1 - /// - /// Per-display width - /// Per-display height - /// Bits per pixel - /// Display frequency - // ReSharper disable once TooManyDependencies - public DisplaySettingsV1(int width, int height, int bitsPerPixel, int frequency) - { - this = typeof(DisplaySettingsV1).Instantiate(); - _Width = (uint) width; - _Height = (uint) height; - _BitsPerPixel = (uint) bitsPerPixel; - _Frequency = (uint) frequency; - } - - - /// - public bool Equals(DisplaySettingsV1 other) - { - return _Width == other._Width && - _Height == other._Height && - _BitsPerPixel == other._BitsPerPixel && - _Frequency == other._Frequency; - } - - /// - public bool Equals(DisplaySettingsV2 other) - { - return _Width == other._Width && - _Height == other._Height && - _BitsPerPixel == other._BitsPerPixel && - _Frequency == other._Frequency; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DisplaySettingsV1 v1 && Equals(v1); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Width; - hashCode = (hashCode * 397) ^ (int) _Height; - hashCode = (hashCode * 397) ^ (int) _BitsPerPixel; - hashCode = (hashCode * 397) ^ (int) _Frequency; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DisplaySettingsV1 left, DisplaySettingsV1 right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DisplaySettingsV1 left, DisplaySettingsV1 right) - { - return !left.Equals(right); - } - - /// - public int Width - { - get => (int) _Width; - } - - /// - public int Height - { - get => (int) _Height; - } - - /// - public int BitsPerPixel - { - get => (int) _BitsPerPixel; - } - - /// - public int Frequency - { - get => (int) _Frequency; - } - - /// - public uint FrequencyInMillihertz - { - get => _Frequency * 1000; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV2.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV2.cs deleted file mode 100644 index 26c9bc02..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplaySettingsV2.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds a display setting - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct DisplaySettingsV2 : IDisplaySettings, - IInitializable, - IEquatable, - IEquatable - { - internal StructureVersion _Version; - internal readonly uint _Width; - internal readonly uint _Height; - internal readonly uint _BitsPerPixel; - internal readonly uint _Frequency; - internal readonly uint _FrequencyInMillihertz; - - /// - /// Creates a new DisplaySettingsV2 - /// - /// Per-display width - /// Per-display height - /// Bits per pixel - /// Display frequency - /// Display frequency in x1k - // ReSharper disable once TooManyDependencies - public DisplaySettingsV2(int width, int height, int bitsPerPixel, int frequency, uint frequencyInMillihertz) - { - this = typeof(DisplaySettingsV2).Instantiate(); - _Width = (uint) width; - _Height = (uint) height; - _BitsPerPixel = (uint) bitsPerPixel; - _Frequency = (uint) frequency; - _FrequencyInMillihertz = frequencyInMillihertz; - } - - /// - public bool Equals(DisplaySettingsV2 other) - { - return _Width == other._Width && - _Height == other._Height && - _BitsPerPixel == other._BitsPerPixel && - _Frequency == other._Frequency && - _FrequencyInMillihertz == other._FrequencyInMillihertz; - } - - /// - public bool Equals(DisplaySettingsV1 other) - { - return _Width == other._Width && - _Height == other._Height && - _BitsPerPixel == other._BitsPerPixel && - _Frequency == other._Frequency; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is DisplaySettingsV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Width; - hashCode = (hashCode * 397) ^ (int) _Height; - hashCode = (hashCode * 397) ^ (int) _BitsPerPixel; - hashCode = (hashCode * 397) ^ (int) _Frequency; - hashCode = (hashCode * 397) ^ (int) _FrequencyInMillihertz; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(DisplaySettingsV2 left, DisplaySettingsV2 right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(DisplaySettingsV2 left, DisplaySettingsV2 right) - { - return !left.Equals(right); - } - - /// - public int Width - { - get => (int) _Width; - } - - /// - public int Height - { - get => (int) _Height; - } - - /// - public int BitsPerPixel - { - get => (int) _BitsPerPixel; - } - - /// - public int Frequency - { - get => (int) _Frequency; - } - - /// - public uint FrequencyInMillihertz - { - get => _FrequencyInMillihertz; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplayTopologyStatus.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/DisplayTopologyStatus.cs deleted file mode 100644 index b3c5a4e0..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/DisplayTopologyStatus.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about a topology validity status - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct DisplayTopologyStatus : IInitializable - { - /// - /// Maximum number of displays for this structure - /// - public const int MaxDisplays = - PhysicalGPUHandle.PhysicalGPUs * Constants.Display.AdvancedDisplayHeads; - - internal StructureVersion _Version; - internal readonly DisplayCapacityProblem _Errors; - internal readonly DisplayTopologyWarning _Warnings; - internal readonly uint _DisplayCounts; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDisplays)] - internal Display[] _Displays; - - /// - /// Gets all error flags for this topology - /// - public DisplayCapacityProblem Errors - { - get => _Errors; - } - - /// - /// Gets all warning flags for this topology - /// - public DisplayTopologyWarning Warnings - { - get => _Warnings; - } - - /// - /// Gets per display statuses - /// - public Display[] Displays - { - get => _Displays.Take((int) _DisplayCounts).ToArray(); - } - - /// - /// Holds information about a display validity status in a topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct Display - { - internal uint _DisplayId; - internal DisplayCapacityProblem _Errors; - internal DisplayTopologyWarning _Warnings; - internal uint _RawReserved; - - /// - /// Gets the Display identification of this display. - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - /// Gets all error flags for this display - /// - public DisplayCapacityProblem Errors - { - get => _Errors; - } - - /// - /// Gets all warning flags for this display - /// - public DisplayTopologyWarning Warnings - { - get => _Warnings; - } - - /// - /// Indicates if this display can be rotated - /// - public bool SupportsRotation - { - get => _RawReserved.GetBit(0); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV1.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV1.cs deleted file mode 100644 index 7f8582d0..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV1.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about a display in a grid topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - public struct GridTopologyDisplayV1 : IGridTopologyDisplay, IEquatable - { - internal readonly uint _DisplayId; - internal readonly int _OverlapX; - internal readonly int _OverlapY; - internal readonly Rotate _Rotation; - internal readonly uint _CloneGroup; - - /// - /// Creates a new GridTopologyDisplayV1 - /// - /// Display identification - /// Horizontal overlap (+overlap, -gap) - /// Vertical overlap (+overlap, -gap) - /// Rotation of display - /// Clone group identification; Reserved, must be 0 - // ReSharper disable once TooManyDependencies - public GridTopologyDisplayV1(uint displayId, int overlapX, int overlapY, Rotate rotation, uint cloneGroup = 0) - : this() - { - _DisplayId = displayId; - _OverlapX = overlapX; - _OverlapY = overlapY; - _Rotation = rotation; - _CloneGroup = cloneGroup; - } - - /// - public bool Equals(GridTopologyDisplayV1 other) - { - return _DisplayId == other._DisplayId && - _OverlapX == other._OverlapX && - _OverlapY == other._OverlapY && - _Rotation == other._Rotation && - _CloneGroup == other._CloneGroup; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is GridTopologyDisplayV1 v1 && Equals(v1); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _DisplayId; - hashCode = (hashCode * 397) ^ _OverlapX; - hashCode = (hashCode * 397) ^ _OverlapY; - hashCode = (hashCode * 397) ^ (int) _Rotation; - hashCode = (hashCode * 397) ^ (int) _CloneGroup; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(GridTopologyDisplayV1 left, GridTopologyDisplayV1 right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(GridTopologyDisplayV1 left, GridTopologyDisplayV1 right) - { - return !left.Equals(right); - } - - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - public int OverlapX - { - get => _OverlapX; - } - - /// - public int OverlapY - { - get => _OverlapY; - } - - /// - public Rotate Rotation - { - get => _Rotation; - } - - /// - public uint CloneGroup - { - get => _CloneGroup; - } - - /// - public PixelShiftType PixelShiftType - { - get => PixelShiftType.NoPixelShift; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV2.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV2.cs deleted file mode 100644 index b5976b78..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyDisplayV2.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.Display; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about a display in a grid topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion] - public struct GridTopologyDisplayV2 : IGridTopologyDisplay, IInitializable, IEquatable - { - internal StructureVersion _Version; - internal readonly uint _DisplayId; - internal readonly int _OverlapX; - internal readonly int _OverlapY; - internal readonly Rotate _Rotation; - internal readonly uint _CloneGroup; - internal readonly PixelShiftType _PixelShiftType; - - /// - /// Creates a new GridTopologyDisplayV2 - /// - /// Display identification - /// Horizontal overlap (+overlap, -gap) - /// Vertical overlap (+overlap, -gap) - /// Rotation of display - /// Clone group identification; Reserved, must be 0 - /// Type of the pixel shift enabled display - // ReSharper disable once TooManyDependencies - public GridTopologyDisplayV2( - uint displayId, - int overlapX, - int overlapY, - Rotate rotation, - uint cloneGroup = 0, - PixelShiftType pixelShiftType = PixelShiftType.NoPixelShift) : this() - { - this = typeof(GridTopologyDisplayV2).Instantiate(); - _DisplayId = displayId; - _OverlapX = overlapX; - _OverlapY = overlapY; - _Rotation = rotation; - _CloneGroup = cloneGroup; - _PixelShiftType = pixelShiftType; - } - - /// - public bool Equals(GridTopologyDisplayV2 other) - { - return _DisplayId == other._DisplayId && - _OverlapX == other._OverlapX && - _OverlapY == other._OverlapY && - _Rotation == other._Rotation && - _CloneGroup == other._CloneGroup && - _PixelShiftType == other._PixelShiftType; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is GridTopologyDisplayV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _DisplayId; - hashCode = (hashCode * 397) ^ _OverlapX; - hashCode = (hashCode * 397) ^ _OverlapY; - hashCode = (hashCode * 397) ^ (int) _Rotation; - hashCode = (hashCode * 397) ^ (int) _CloneGroup; - hashCode = (hashCode * 397) ^ (int) _PixelShiftType; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(GridTopologyDisplayV2 left, GridTopologyDisplayV2 right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(GridTopologyDisplayV2 left, GridTopologyDisplayV2 right) - { - return !left.Equals(right); - } - - /// - public uint DisplayId - { - get => _DisplayId; - } - - /// - public int OverlapX - { - get => _OverlapX; - } - - /// - public int OverlapY - { - get => _OverlapY; - } - - /// - public Rotate Rotation - { - get => _Rotation; - } - - /// - public uint CloneGroup - { - get => _CloneGroup; - } - - /// - public PixelShiftType PixelShiftType - { - get => _PixelShiftType; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV1.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV1.cs deleted file mode 100644 index 76d9ae92..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV1.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about a grid topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct GridTopologyV1 : IGridTopology, IInitializable, IEquatable - { - /// - /// Maximum number of displays in a topology - /// - public const int MaxDisplays = 64; - - internal StructureVersion _Version; - internal readonly uint _Rows; - internal readonly uint _Columns; - internal readonly uint _DisplayCount; - internal uint _RawReserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDisplays)] - internal readonly GridTopologyDisplayV1[] _Displays; - - internal readonly DisplaySettingsV1 _DisplaySettings; - - /// - /// Creates a new GridTopologyV1 - /// - /// Number of rows - /// Number of columns - /// Topology displays; Displays are done as [(row * columns) + column] - /// Display settings - /// - /// When enabling and doing the modeset, do we switch to the - /// bezel-corrected resolution - /// - /// Enable as immersive gaming instead of Mosaic SLI (for Quadro-boards only) - /// - /// Enable as Base Mosaic (Panoramic) instead of Mosaic SLI (for NVS and Quadro-boards - /// only) - /// - /// - /// If necessary, reloading the driver is permitted (for Vista and above only). Will not - /// be persisted. - /// - /// - /// Enable SLI acceleration on the primary display while in single-wide mode (For - /// Immersive Gaming only). Will not be persisted. - /// - /// Total number of topology displays is below or equal to zero - /// Number of displays doesn't match the arrangement - // ReSharper disable once TooManyDependencies - public GridTopologyV1( - int rows, - int columns, - GridTopologyDisplayV1[] displays, - DisplaySettingsV1 displaySettings, - bool applyWithBezelCorrectedResolution, - bool immersiveGaming, - bool baseMosaicPanoramic, - bool driverReloadAllowed, - bool acceleratePrimaryDisplay) - { - if (rows * columns <= 0) - { - throw new ArgumentOutOfRangeException($"{nameof(rows)}, {nameof(columns)}", - "Invalid display arrangement."); - } - - if (displays.Length > MaxDisplays) - { - throw new ArgumentException("Too many displays."); - } - - if (displays.Length != rows * columns) - { - throw new ArgumentException("Number of displays should match the arrangement.", nameof(displays)); - } - - this = typeof(GridTopologyV1).Instantiate(); - _Rows = (uint) rows; - _Columns = (uint) columns; - _DisplayCount = (uint) displays.Length; - _Displays = displays; - _DisplaySettings = displaySettings; - ApplyWithBezelCorrectedResolution = applyWithBezelCorrectedResolution; - ImmersiveGaming = immersiveGaming; - BaseMosaicPanoramic = baseMosaicPanoramic; - DriverReloadAllowed = driverReloadAllowed; - AcceleratePrimaryDisplay = acceleratePrimaryDisplay; - Array.Resize(ref _Displays, MaxDisplays); - } - - /// - public bool Equals(GridTopologyV1 other) - { - return _Rows == other._Rows && - _Columns == other._Columns && - _DisplayCount == other._DisplayCount && - _RawReserved == other._RawReserved && - _Displays.SequenceEqual(other._Displays) && - _DisplaySettings.Equals(other._DisplaySettings); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is GridTopologyV1 v1 && Equals(v1); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Rows; - hashCode = (hashCode * 397) ^ (int) _Columns; - hashCode = (hashCode * 397) ^ (int) _DisplayCount; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ (int) _RawReserved; - hashCode = (hashCode * 397) ^ (_Displays?.GetHashCode() ?? 0); - hashCode = (hashCode * 397) ^ _DisplaySettings.GetHashCode(); - - return hashCode; - } - } - - /// - public int Rows - { - get => (int) _Rows; - } - - /// - public int Columns - { - get => (int) _Columns; - } - - /// - public IEnumerable Displays - { - get => _Displays.Take((int) _DisplayCount).Cast(); - } - - /// - public DisplaySettingsV1 DisplaySettings - { - get => _DisplaySettings; - } - - /// - public bool ApplyWithBezelCorrectedResolution - { - get => _RawReserved.GetBit(0); - private set => _RawReserved = _RawReserved.SetBit(0, value); - } - - /// - public bool ImmersiveGaming - { - get => _RawReserved.GetBit(1); - private set => _RawReserved = _RawReserved.SetBit(1, value); - } - - /// - public bool BaseMosaicPanoramic - { - get => _RawReserved.GetBit(2); - private set => _RawReserved = _RawReserved.SetBit(2, value); - } - - /// - public bool DriverReloadAllowed - { - get => _RawReserved.GetBit(3); - private set => _RawReserved = _RawReserved.SetBit(3, value); - } - - /// - public bool AcceleratePrimaryDisplay - { - get => _RawReserved.GetBit(4); - private set => _RawReserved = _RawReserved.SetBit(4, value); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV2.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV2.cs deleted file mode 100644 index 4379abc0..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/GridTopologyV2.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about a grid topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct GridTopologyV2 : IGridTopology, IInitializable, IEquatable - { - /// - /// Maximum number of displays in a topology - /// - public const int MaxDisplays = GridTopologyV1.MaxDisplays; - - internal StructureVersion _Version; - internal readonly uint _Rows; - internal readonly uint _Columns; - internal readonly uint _DisplayCount; - internal uint _RawReserved; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxDisplays)] - internal readonly GridTopologyDisplayV2[] _Displays; - - internal readonly DisplaySettingsV1 _DisplaySettings; - - /// - /// Creates a new GridTopologyV2 - /// - /// Number of rows - /// Number of columns - /// Topology displays; Displays are done as [(row * columns) + column] - /// Display settings - /// - /// When enabling and doing the mode-set, do we switch to the - /// bezel-corrected resolution - /// - /// Enable as immersive gaming instead of Mosaic SLI (for Quadro-boards only) - /// - /// Enable as Base Mosaic (Panoramic) instead of Mosaic SLI (for NVS and Quadro-boards - /// only) - /// - /// - /// If necessary, reloading the driver is permitted (for Vista and above only). Will not - /// be persisted. - /// - /// - /// Enable SLI acceleration on the primary display while in single-wide mode (For - /// Immersive Gaming only). Will not be persisted. - /// - /// Enable Pixel shift - /// Total number of topology displays is below or equal to zero - /// Number of displays doesn't match the arrangement - // ReSharper disable once TooManyDependencies - public GridTopologyV2( - int rows, - int columns, - GridTopologyDisplayV2[] displays, - DisplaySettingsV1 displaySettings, - bool applyWithBezelCorrectedResolution, - bool immersiveGaming, - bool baseMosaicPanoramic, - bool driverReloadAllowed, - bool acceleratePrimaryDisplay, - bool pixelShift) - { - if (rows * columns <= 0) - { - throw new ArgumentOutOfRangeException($"{nameof(rows)}, {nameof(columns)}", - "Invalid display arrangement."); - } - - if (displays.Length > MaxDisplays) - { - throw new ArgumentException("Too many displays."); - } - - if (displays.Length != rows * columns) - { - throw new ArgumentException("Number of displays should match the arrangement.", nameof(displays)); - } - - this = typeof(GridTopologyV2).Instantiate(); - _Rows = (uint) rows; - _Columns = (uint) columns; - _DisplayCount = (uint) displays.Length; - _Displays = displays; - _DisplaySettings = displaySettings; - ApplyWithBezelCorrectedResolution = applyWithBezelCorrectedResolution; - ImmersiveGaming = immersiveGaming; - BaseMosaicPanoramic = baseMosaicPanoramic; - DriverReloadAllowed = driverReloadAllowed; - AcceleratePrimaryDisplay = acceleratePrimaryDisplay; - PixelShift = pixelShift; - Array.Resize(ref _Displays, MaxDisplays); - } - - /// - public bool Equals(GridTopologyV2 other) - { - return _Rows == other._Rows && - _Columns == other._Columns && - _DisplayCount == other._DisplayCount && - _RawReserved == other._RawReserved && - _Displays.SequenceEqual(other._Displays) && - _DisplaySettings.Equals(other._DisplaySettings); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is GridTopologyV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _Rows; - hashCode = (hashCode * 397) ^ (int) _Columns; - hashCode = (hashCode * 397) ^ (int) _DisplayCount; - // ReSharper disable once NonReadonlyMemberInGetHashCode - hashCode = (hashCode * 397) ^ (int) _RawReserved; - hashCode = (hashCode * 397) ^ (_Displays?.GetHashCode() ?? 0); - hashCode = (hashCode * 397) ^ _DisplaySettings.GetHashCode(); - - return hashCode; - } - } - - /// - public int Rows - { - get => (int) _Rows; - } - - /// - public int Columns - { - get => (int) _Columns; - } - - /// - public IEnumerable Displays - { - get => _Displays.Take((int) _DisplayCount).Cast(); - } - - /// - public DisplaySettingsV1 DisplaySettings - { - get => _DisplaySettings; - } - - /// - public bool ApplyWithBezelCorrectedResolution - { - get => _RawReserved.GetBit(0); - private set => _RawReserved = _RawReserved.SetBit(0, value); - } - - /// - public bool ImmersiveGaming - { - get => _RawReserved.GetBit(1); - private set => _RawReserved = _RawReserved.SetBit(1, value); - } - - /// - public bool BaseMosaicPanoramic - { - get => _RawReserved.GetBit(2); - private set => _RawReserved = _RawReserved.SetBit(2, value); - } - - /// - public bool DriverReloadAllowed - { - get => _RawReserved.GetBit(3); - private set => _RawReserved = _RawReserved.SetBit(3, value); - } - - /// - public bool AcceleratePrimaryDisplay - { - get => _RawReserved.GetBit(4); - private set => _RawReserved = _RawReserved.SetBit(4, value); - } - - /// - /// Enable Pixel shift - /// - public bool PixelShift - { - get => _RawReserved.GetBit(5); - private set => _RawReserved = _RawReserved.SetBit(5, value); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV1.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV1.cs deleted file mode 100644 index 3f7efffb..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV1.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about supported topologies - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct SupportedTopologiesInfoV1 : ISupportedTopologiesInfo, - IInitializable, - IEquatable - { - /// - /// Maximum number of display settings possible to retrieve - /// - public const int MaxSettings = 40; - - internal StructureVersion _Version; - internal readonly uint _TopologyBriefsCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int) Topology.Max)] - internal readonly TopologyBrief[] - _TopologyBriefs; - - internal readonly uint _DisplaySettingsCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSettings)] - internal readonly DisplaySettingsV1[] - _DisplaySettings; - - /// - public bool Equals(SupportedTopologiesInfoV1 other) - { - return _TopologyBriefsCount == other._TopologyBriefsCount && - _TopologyBriefs.SequenceEqual(other._TopologyBriefs) && - _DisplaySettingsCount == other._DisplaySettingsCount && - _DisplaySettings.SequenceEqual(other._DisplaySettings); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is SupportedTopologiesInfoV1 v1 && Equals(v1); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _TopologyBriefsCount; - hashCode = (hashCode * 397) ^ (_TopologyBriefs?.GetHashCode() ?? 0); - hashCode = (hashCode * 397) ^ (int) _DisplaySettingsCount; - hashCode = (hashCode * 397) ^ (_DisplaySettings?.GetHashCode() ?? 0); - - return hashCode; - } - } - - /// - public IEnumerable TopologyBriefs - { - get => _TopologyBriefs.Take((int) _TopologyBriefsCount); - } - - /// - public IEnumerable DisplaySettings - { - get => _DisplaySettings.Take((int) _DisplaySettingsCount).Cast(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV2.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV2.cs deleted file mode 100644 index ba412134..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/SupportedTopologiesInfoV2.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; -using NvAPIWrapper.Native.Interfaces.Mosaic; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds information about supported topologies - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(2)] - public struct SupportedTopologiesInfoV2 : ISupportedTopologiesInfo, - IInitializable, - IEquatable - { - /// - /// Maximum number of display settings possible to retrieve - /// - public const int MaxSettings = SupportedTopologiesInfoV1.MaxSettings; - - internal StructureVersion _Version; - internal readonly uint _TopologyBriefsCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int) Topology.Max)] - internal readonly TopologyBrief[] - _TopologyBriefs; - - internal readonly uint _DisplaySettingsCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxSettings)] - internal readonly DisplaySettingsV2[] - _DisplaySettings; - - /// - public bool Equals(SupportedTopologiesInfoV2 other) - { - return _TopologyBriefsCount == other._TopologyBriefsCount && - _TopologyBriefs.SequenceEqual(other._TopologyBriefs) && - _DisplaySettingsCount == other._DisplaySettingsCount && - _DisplaySettings.SequenceEqual(other._DisplaySettings); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is SupportedTopologiesInfoV2 v2 && Equals(v2); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = (int) _TopologyBriefsCount; - hashCode = (hashCode * 397) ^ (_TopologyBriefs?.GetHashCode() ?? 0); - hashCode = (hashCode * 397) ^ (int) _DisplaySettingsCount; - hashCode = (hashCode * 397) ^ (_DisplaySettings?.GetHashCode() ?? 0); - - return hashCode; - } - } - - /// - public IEnumerable TopologyBriefs - { - get => _TopologyBriefs.Take((int) _TopologyBriefsCount); - } - - /// - public IEnumerable DisplaySettings - { - get => _DisplaySettings.Take((int) _DisplaySettingsCount).Cast(); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyBrief.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyBrief.cs deleted file mode 100644 index 093f559f..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyBrief.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds brief information about a topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct TopologyBrief : IInitializable, IEquatable - { - internal StructureVersion _Version; - internal readonly Topology _Topology; - internal readonly uint _IsEnable; - internal readonly uint _IsPossible; - - /// - /// Creates a new TopologyBrief - /// - /// The topology - public TopologyBrief(Topology topology) - { - this = typeof(TopologyBrief).Instantiate(); - _Topology = topology; - } - - /// - public bool Equals(TopologyBrief other) - { - return _Topology == other._Topology; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is TopologyBrief brief && Equals(brief); - } - - /// - public override int GetHashCode() - { - return (int) _Topology; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(TopologyBrief left, TopologyBrief right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(TopologyBrief left, TopologyBrief right) - { - return !left.Equals(right); - } - - /// - /// The topology - /// - public Topology Topology - { - get => _Topology; - } - - /// - /// Indicates if the topology is enable - /// - public bool IsEnable - { - get => _IsEnable > 0; - } - - /// - /// Indicates if the topology is possible - /// - public bool IsPossible - { - get => _IsPossible > 0; - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyDetails.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyDetails.cs deleted file mode 100644 index c668b222..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyDetails.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.GPU; -using NvAPIWrapper.Native.GPU.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// Holds extra details about a topology - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct TopologyDetails : IInitializable, IEquatable - { - /// - /// Maximum number of rows in a topology detail - /// - public const int MaxLayoutRows = 8; - - /// - /// Maximum number of columns in a topology detail - /// - public const int MaxLayoutColumns = 8; - - internal StructureVersion _Version; - internal readonly LogicalGPUHandle _LogicalGPUHandle; - internal readonly TopologyValidity _ValidityFlags; - internal readonly uint _Rows; - internal readonly uint _Columns; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxLayoutRows)] - internal readonly LayoutRow[] _LayoutRows; - - /// - public bool Equals(TopologyDetails other) - { - return _LogicalGPUHandle.Equals(other._LogicalGPUHandle) && - _ValidityFlags == other._ValidityFlags && - _Rows == other._Rows && - _Columns == other._Columns && - _LayoutRows.SequenceEqual(other._LayoutRows); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is TopologyDetails details && Equals(details); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = _LogicalGPUHandle.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _ValidityFlags; - hashCode = (hashCode * 397) ^ (int) _Rows; - hashCode = (hashCode * 397) ^ (int) _Columns; - hashCode = (hashCode * 397) ^ (_LayoutRows?.GetHashCode() ?? 0); - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(TopologyDetails left, TopologyDetails right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(TopologyDetails left, TopologyDetails right) - { - return !left.Equals(right); - } - - /// - /// Logical GPU for this topology - /// - public LogicalGPUHandle LogicalGPUHandle - { - get => _LogicalGPUHandle; - } - - /// - /// Indicates topology validity. TopologyValidity.Valid means topology is valid with the current hardware. - /// - public TopologyValidity ValidityFlags - { - get => _ValidityFlags; - } - - /// - /// Number of displays in a row - /// - public int Rows - { - get => (int) _Rows; - } - - /// - /// Number of displays in a column - /// - public int Columns - { - get => (int) _Columns; - } - - /// - /// Gets a 2D array of layout cells containing information about the display layout of the topology - /// - public LayoutCell[][] Layout - { - get - { - var columns = (int) _Columns; - - return _LayoutRows.Take((int) _Rows).Select(row => row.LayoutCells.Take(columns).ToArray()).ToArray(); - } - } - - [StructLayout(LayoutKind.Sequential)] - internal struct LayoutRow : IInitializable, IEquatable - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxLayoutColumns)] - internal readonly LayoutCell[] - LayoutCells; - - public bool Equals(LayoutRow other) - { - return LayoutCells.SequenceEqual(other.LayoutCells); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is LayoutRow row && Equals(row); - } - - public override int GetHashCode() - { - return LayoutCells?.GetHashCode() ?? 0; - } - } - - /// - /// Holds information about a topology display - /// - [StructLayout(LayoutKind.Sequential)] - public struct LayoutCell : IEquatable - { - internal readonly PhysicalGPUHandle _PhysicalGPUHandle; - internal readonly OutputId _DisplayOutputId; - internal readonly int _OverlapX; - internal readonly int _OverlapY; - - /// - public bool Equals(LayoutCell other) - { - return _PhysicalGPUHandle.Equals(other._PhysicalGPUHandle) && - _DisplayOutputId == other._DisplayOutputId && - _OverlapX == other._OverlapX && - _OverlapY == other._OverlapY; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is LayoutCell cell && Equals(cell); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = _PhysicalGPUHandle.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _DisplayOutputId; - hashCode = (hashCode * 397) ^ _OverlapX; - hashCode = (hashCode * 397) ^ _OverlapY; - - return hashCode; - } - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(LayoutCell left, LayoutCell right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(LayoutCell left, LayoutCell right) - { - return !left.Equals(right); - } - - /// - /// Physical GPU to be used in the topology (0 if GPU missing) - /// - public PhysicalGPUHandle PhysicalGPUHandle - { - get => _PhysicalGPUHandle; - } - - /// - /// Connected display target (0 if no display connected) - /// - public OutputId DisplayOutputId - { - get => _DisplayOutputId; - } - - /// - /// Pixels of overlap on left of target: (+overlap, -gap) - /// - public int OverlapX - { - get => _OverlapX; - } - - /// - /// Pixels of overlap on top of target: (+overlap, -gap) - /// - public int OverlapY - { - get => _OverlapY; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyGroup.cs b/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyGroup.cs deleted file mode 100644 index bcc088c3..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Structures/TopologyGroup.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Linq; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Mosaic.Structures -{ - /// - /// This structure defines a group of topologies that work together to create one overall layout. All of the supported - /// topologies are represented with this structure. - /// For example, a 'Passive Stereo' topology would be represented with this structure, and would have separate topology - /// details for the left and right eyes. The count would be 2. A 'Basic' topology is also represented by this - /// structure, with a count of 1. - /// The structure is primarily used internally, but is exposed to applications in a read-only fashion because there are - /// some details in it that might be useful (like the number of rows/cols, or connected display information). A user - /// can get the filled-in structure by calling NvAPI_Mosaic_GetTopoGroup(). - /// You can then look at the detailed values within the structure. There are no entry points which take this structure - /// as input (effectively making it read-only). - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct TopologyGroup : IInitializable, IEquatable - { - /// - /// Maximum number of topologies per each group - /// - public const int MaxTopologyPerGroup = 2; - - internal StructureVersion _Version; - internal readonly TopologyBrief _Brief; - internal readonly uint _TopologiesCount; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxTopologyPerGroup)] - internal readonly TopologyDetails[] - _TopologyDetails; - - /// - /// The brief details of this topology - /// - public TopologyBrief Brief - { - get => _Brief; - } - - /// - /// Information about the topologies within this group - /// - public TopologyDetails[] TopologyDetails - { - get => _TopologyDetails.Take((int) _TopologiesCount).ToArray(); - } - - /// - public bool Equals(TopologyGroup other) - { - return _Brief.Equals(other._Brief) && - _TopologiesCount == other._TopologiesCount && - _TopologyDetails.SequenceEqual(other._TopologyDetails); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is TopologyGroup group && Equals(group); - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(TopologyGroup left, TopologyGroup right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(TopologyGroup left, TopologyGroup right) - { - return !left.Equals(right); - } - - /// - public override int GetHashCode() - { - unchecked - { - var hashCode = _Brief.GetHashCode(); - hashCode = (hashCode * 397) ^ (int) _TopologiesCount; - hashCode = (hashCode * 397) ^ (_TopologyDetails?.GetHashCode() ?? 0); - - return hashCode; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/Topology.cs b/app/NvAPIWrapper/Native/Mosaic/Topology.cs deleted file mode 100644 index b53843fe..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/Topology.cs +++ /dev/null @@ -1,133 +0,0 @@ -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// Complete list of supported Mosaic topologies. - /// Using a "Basic" topology combines multiple monitors to create a single desktop. - /// Using a "Passive" topology combines multiples monitors to create a passive stereo desktop. - /// In passive stereo, two identical topologies combine - one topology is used for the right eye and the other - /// identical topology (targeting different displays) is used for the left eye. - /// - public enum Topology - { - /// - /// Not a Mosaic Topology - /// - None = 0, - - // Basic_Begin = 1, - - /// - /// 1x2 Basic Topology Configuration - /// - Basic_1X2 = 1, - - /// - /// 2x1 Basic Topology Configuration - /// - Basic_2X1 = 2, - - /// - /// 1x3 Basic Topology Configuration - /// - Basic_1X3 = 3, - - /// - /// 3x1 Basic Topology Configuration - /// - Basic_3X1 = 4, - - /// - /// 4x1 Basic Topology Configuration - /// - Basic_1X4 = 5, - - /// - /// 4x1 Basic Topology Configuration - /// - Basic_4X1 = 6, - - /// - /// 2x2 Basic Topology Configuration - /// - Basic_2X2 = 7, - - /// - /// 2x3 Basic Topology Configuration - /// - Basic_2X3 = 8, - - /// - /// 2x4 Basic Topology Configuration - /// - Basic_2X4 = 9, - - /// - /// 3x2 Basic Topology Configuration - /// - Basic_3X2 = 10, - - /// - /// 4x2 Basic Topology Configuration - /// - Basic_4X2 = 11, - - /// - /// 1x5 Basic Topology Configuration - /// - Basic_1X5 = 12, - - /// - /// 1x6 Basic Topology Configuration - /// - Basic_1X6 = 13, - - /// - /// 7x1 Basic Topology Configuration - /// - Basic_7X1 = 14, - - // Basic_End = 23, - // PassiveStereo_Begin = 24, - - /// - /// 1x2 Passive Stereo Configuration - /// - PassiveStereo_1X2 = 24, - - /// - /// 2x1 Passive Stereo Configuration - /// - PassiveStereo_2X1 = 25, - - /// - /// 1x3 Passive Stereo Configuration - /// - PassiveStereo_1X3 = 26, - - /// - /// 3x1 Passive Stereo Configuration - /// - PassiveStereo_3X1 = 27, - - /// - /// 1x4 Passive Stereo Configuration - /// - PassiveStereo_1X4 = 28, - - /// - /// 4x1 Passive Stereo Configuration - /// - PassiveStereo_4X1 = 29, - - /// - /// 2x2 Passive Stereo Configuration - /// - PassiveStereo_2X2 = 30, - - // PassiveStereo_End = 34, - /// - /// Indicator for the max number of possible configuration, DO NOT USE - /// - Max = 34 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/TopologyType.cs b/app/NvAPIWrapper/Native/Mosaic/TopologyType.cs deleted file mode 100644 index 176b9923..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/TopologyType.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// These values refer to the different types of Mosaic topologies that are possible. When getting the supported Mosaic - /// topologies, you can specify one of these types to narrow down the returned list to only those that match the given - /// type. - /// - public enum TopologyType - { - /// - /// All mosaic topologies - /// - All = 0, - - /// - /// Basic Mosaic topologies - /// - Basic = 1, - - /// - /// Passive Stereo topologies - /// - PassiveStereo = 2, - - /// - /// Not supported at this time - /// - ScaledClone = 3, - - /// - /// Not supported at this time - /// - PassiveStereoScaledClone = 4 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Mosaic/TopologyValidity.cs b/app/NvAPIWrapper/Native/Mosaic/TopologyValidity.cs deleted file mode 100644 index 0131c17e..00000000 --- a/app/NvAPIWrapper/Native/Mosaic/TopologyValidity.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace NvAPIWrapper.Native.Mosaic -{ - /// - /// These bits are used to describe the validity of a topo - /// - [Flags] - public enum TopologyValidity : uint - { - /// - /// The topology is valid - /// - Valid = 0, - - /// - /// Not enough SLI GPUs were found to fill the entire topology. PhysicalGPUHandle will be null for these. - /// - MissingGPU = 1, - - /// - /// Not enough displays were found to fill the entire topology. Output identification will be 0 for these. - /// - MissingDisplay = 2, - - /// - /// The topology is only possible with displays of the same output type. Check output identifications to make sure they - /// are all CRTs, or all DFPs. - /// - MixedDisplayTypes = 4 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/MosaicApi.cs b/app/NvAPIWrapper/Native/MosaicApi.cs deleted file mode 100644 index 1fff83dc..00000000 --- a/app/NvAPIWrapper/Native/MosaicApi.cs +++ /dev/null @@ -1,480 +0,0 @@ -using System; -using System.Linq; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Interfaces.Mosaic; -using NvAPIWrapper.Native.Mosaic; -using NvAPIWrapper.Native.Mosaic.Structures; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains mosaic and topology static functions - /// - public static class MosaicApi - { - /// - /// This API enables or disables the current Mosaic topology based on the setting of the incoming 'enable' parameter. - /// An "enable" setting enables the current (previously set) Mosaic topology. - /// Note that when the current Mosaic topology is retrieved, it must have an isPossible value of true or an error will - /// occur. - /// A "disable" setting disables the current Mosaic topology. - /// The topology information will persist, even across reboots. - /// To re-enable the Mosaic topology, call this function again with the enable parameter set to true. - /// - /// true to enable the current Mosaic topo, false to disable it. - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.TopologyNotPossible: The current topology is not currently possible. - /// Status.ModeChangeFailed: There was an error changing the display mode. - /// Status.Error: Miscellaneous error occurred. - public static void EnableCurrentTopology(bool enable) - { - var status = - DelegateFactory.GetDelegate()((uint) (enable ? 1 : 0)); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// Enumerates the current active grid topologies. This includes Mosaic, IG, and Panoramic topologies, as well as - /// single displays. - /// - /// The list of active grid topologies. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - /// This operation is not supported. - /// A delegate callback throws an exception. - public static IGridTopology[] EnumDisplayGrids() - { - var mosaicEnumDisplayGrids = - DelegateFactory.GetDelegate(); - - var totalAvailable = 0u; - var status = mosaicEnumDisplayGrids(ValueTypeArray.Null, ref totalAvailable); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (totalAvailable == 0) - { - return new IGridTopology[0]; - } - - foreach (var acceptType in mosaicEnumDisplayGrids.Accepts()) - { - var counts = totalAvailable; - var instance = acceptType.Instantiate(); - - using ( - var gridTopologiesByRef = ValueTypeArray.FromArray(instance.Repeat((int) counts).AsEnumerable())) - { - status = mosaicEnumDisplayGrids(gridTopologiesByRef, ref counts); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return gridTopologiesByRef.ToArray((int) counts, acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// Determines the set of available display modes for a given grid topology. - /// - /// The grid topology to use. - /// - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - /// This operation is not supported. - /// A delegate callback throws an exception. - public static IDisplaySettings[] EnumDisplayModes(IGridTopology gridTopology) - { - var mosaicEnumDisplayModes = DelegateFactory.GetDelegate(); - - using (var gridTopologyByRef = ValueTypeReference.FromValueType(gridTopology, gridTopology.GetType())) - { - var totalAvailable = 0u; - var status = mosaicEnumDisplayModes(gridTopologyByRef, ValueTypeArray.Null, ref totalAvailable); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (totalAvailable == 0) - { - return new IDisplaySettings[0]; - } - - foreach (var acceptType in mosaicEnumDisplayModes.Accepts(2)) - { - var counts = totalAvailable; - var instance = acceptType.Instantiate(); - - using ( - var displaySettingByRef = - ValueTypeArray.FromArray(instance.Repeat((int) counts).AsEnumerable())) - { - status = mosaicEnumDisplayModes(gridTopologyByRef, displaySettingByRef, ref counts); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return displaySettingByRef.ToArray((int) counts, acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - } - - /// - /// This API returns information for the current Mosaic topology. - /// This includes topology, display settings, and overlap values. - /// You can call NvAPI_Mosaic_GetTopoGroup() with the topology if you require more information. - /// If there isn't a current topology, then TopologyBrief.Topology will be Topology.None. - /// - /// The current Mosaic topology - /// The current per-display settings - /// The pixel overlap between horizontal displays - /// The pixel overlap between vertical displays - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - /// This operation is not supported. - /// A delegate callback throws an exception. - // ReSharper disable once TooManyArguments - public static void GetCurrentTopology( - out TopologyBrief topoBrief, - out IDisplaySettings displaySettings, - out int overlapX, - out int overlapY) - { - var mosaicGetCurrentTopo = DelegateFactory.GetDelegate(); - topoBrief = typeof(TopologyBrief).Instantiate(); - - foreach (var acceptType in mosaicGetCurrentTopo.Accepts()) - { - displaySettings = acceptType.Instantiate(); - - using (var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, acceptType)) - { - var status = mosaicGetCurrentTopo(ref topoBrief, displaySettingsByRef, out overlapX, out overlapY); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - displaySettings = displaySettingsByRef.ToValueType(acceptType); - - return; - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API returns the X and Y overlap limits required if the given Mosaic topology and display settings are to be - /// used. - /// - /// - /// The topology for getting limits This must be one of the topo briefs returned from - /// GetSupportedTopoInfo(). - /// - /// - /// The display settings for getting the limits. This must be one of the settings returned - /// from GetSupportedTopoInfo(). - /// - /// X overlap minimum - /// X overlap maximum - /// Y overlap minimum - /// Y overlap maximum - /// displaySettings is of invalid type. - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - /// A delegate callback throws an exception. - // ReSharper disable once TooManyArguments - public static void GetOverlapLimits( - TopologyBrief topoBrief, - IDisplaySettings displaySettings, - out int minOverlapX, - out int maxOverlapX, - out int minOverlapY, - out int maxOverlapY) - { - var mosaicGetOverlapLimits = DelegateFactory.GetDelegate(); - - if (!mosaicGetOverlapLimits.Accepts().Contains(displaySettings.GetType())) - { - throw new ArgumentException("Parameter type is not supported.", nameof(displaySettings)); - } - - using ( - var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, displaySettings.GetType())) - { - var status = mosaicGetOverlapLimits(topoBrief, displaySettingsByRef, out minOverlapX, out maxOverlapX, - out minOverlapY, out maxOverlapY); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// This API returns information on the topologies and display resolutions supported by Mosaic mode. - /// NOTE: Not all topologies returned can be set immediately. Some of the topologies returned might not be valid for - /// one reason or another. It could be due to mismatched or missing displays. It could also be because the required - /// number of GPUs is not found. - /// Once you get the list of supported topologies, you can call GetTopologyGroup() with one of the Mosaic topologies if - /// you need more information about it. - /// It is possible for this function to return NVAPI_OK with no topologies listed in the return structure. If this is - /// the case, it means that the current hardware DOES support Mosaic, but with the given configuration no valid - /// topologies were found. This most likely means that SLI was not enabled for the hardware. Once enabled, you should - /// see valid topologies returned from this function. - /// - /// The type of topologies the caller is interested in getting. - /// Information about what topologies and display resolutions are supported for Mosaic. - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: TopologyType is invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry-point not available. - /// Status.Error: Miscellaneous error occurred. - /// This operation is not supported. - /// A delegate callback throws an exception. - public static ISupportedTopologiesInfo GetSupportedTopologiesInfo(TopologyType topologyType) - { - var mosaicGetSupportedTopoInfo = - DelegateFactory.GetDelegate(); - - foreach (var acceptType in mosaicGetSupportedTopoInfo.Accepts()) - { - var instance = acceptType.Instantiate(); - - using (var supportedTopologiesInfoByRef = ValueTypeReference.FromValueType(instance, acceptType)) - { - var status = mosaicGetSupportedTopoInfo(supportedTopologiesInfoByRef, topologyType); - - if (status == Status.IncompatibleStructureVersion) - { - continue; - } - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return supportedTopologiesInfoByRef.ToValueType(acceptType); - } - } - - throw new NVIDIANotSupportedException("This operation is not supported."); - } - - /// - /// This API returns a structure filled with the details of the specified Mosaic topology. - /// If the pTopoBrief passed in matches the current topology, then information in the brief and group structures will - /// reflect what is current. Thus the brief would have the current 'enable' status, and the group would have the - /// current overlap values. If there is no match, then the returned brief has an 'enable' status of FALSE (since it is - /// obviously not enabled), and the overlap values will be 0. - /// - /// - /// The topology for getting the details. This must be one of the topology briefs returned from - /// GetSupportedTopoInfo(). - /// - /// The topology details matching the brief - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - public static TopologyGroup GetTopologyGroup(TopologyBrief topoBrief) - { - var result = typeof(TopologyGroup).Instantiate(); - var status = - DelegateFactory.GetDelegate()(topoBrief, ref result); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return result; - } - - /// - /// This API sets the Mosaic topology and performs a mode switch using the given display settings. - /// - /// - /// The topology to set. This must be one of the topologies returned from GetSupportedTopoInfo(), - /// and it must have an isPossible value of true. - /// - /// - /// The per display settings to be used in the Mosaic mode. This must be one of the settings - /// returned from GetSupportedTopoInfo(). - /// - /// - /// The pixel overlap to use between horizontal displays (use positive a number for overlap, or a - /// negative number to create a gap.) If the overlap is out of bounds for what is possible given the topo and display - /// setting, the overlap will be clamped. - /// - /// - /// The pixel overlap to use between vertical displays (use positive a number for overlap, or a - /// negative number to create a gap.) If the overlap is out of bounds for what is possible given the topo and display - /// setting, the overlap will be clamped. - /// - /// - /// If true, the topology being set will also be enabled, meaning that the mode set will occur. If - /// false, you don't want to be in Mosaic mode right now, but want to set the current Mosaic topology so you can enable - /// it later with EnableCurrentTopo() - /// - /// displaySettings is of invalid type. - /// Status.NotSupported: Mosaic is not supported with the existing hardware. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - /// A delegate callback throws an exception. - // ReSharper disable once TooManyArguments - public static void SetCurrentTopology( - TopologyBrief topoBrief, - IDisplaySettings displaySettings, - int overlapX, - int overlapY, - bool enable) - { - var mosaicSetCurrentTopo = DelegateFactory.GetDelegate(); - - if (!mosaicSetCurrentTopo.Accepts().Contains(displaySettings.GetType())) - { - throw new ArgumentException("Parameter type is not supported.", nameof(displaySettings)); - } - - using ( - var displaySettingsByRef = ValueTypeReference.FromValueType(displaySettings, displaySettings.GetType())) - { - var status = mosaicSetCurrentTopo(topoBrief, displaySettingsByRef, overlapX, overlapY, - (uint) (enable ? 1 : 0)); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// Sets a new display topology, replacing any existing topologies that use the same displays. - /// This function will look for an SLI configuration that will allow the display topology to work. - /// To revert to a single display, specify that display as a 1x1 grid. - /// - /// The topology details to set. - /// One of the SetDisplayTopologyFlag flags - /// Status.TopologyNotPossible: One or more of the display grids are not valid. - /// Status.NoActiveSLITopology: No matching GPU topologies could be found. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - public static void SetDisplayGrids( - IGridTopology[] gridTopologies, - SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.NoFlag) - { - using (var gridTopologiesByRef = ValueTypeArray.FromArray(gridTopologies.AsEnumerable())) - { - var status = - DelegateFactory.GetDelegate()(gridTopologiesByRef, - (uint) gridTopologies.Length, - flags); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } - - /// - /// Determines if a list of grid topologies is valid. It will choose an SLI configuration in the same way that - /// SetDisplayGrids() does. - /// On return, each element in the pTopoStatus array will contain any errors or warnings about each grid topology. If - /// any error flags are set, then the topology is not valid. If any warning flags are set, then the topology is valid, - /// but sub-optimal. - /// If the ALLOW_INVALID flag is set, then it will continue to validate the grids even if no SLI configuration will - /// allow all of the grids. In this case, a grid grid with no matching GPU topology will have the error flags - /// NO_GPU_TOPOLOGY or NOT_SUPPORTED set. - /// If the ALLOW_INVALID flag is not set and no matching SLI configuration is found, then it will skip the rest of the - /// validation and throws a NVIDIAApiException with Status.NoActiveSLITopology. - /// - /// The array of grid topologies to verify. - /// One of the SetDisplayTopologyFlag flags - /// Status.NoActiveSLITopology: No matching GPU topologies could be found. - /// Status.InvalidArgument: One or more arguments passed in are invalid. - /// Status.ApiNotInitialized: The NvAPI API needs to be initialized first. - /// Status.NoImplementation: This entry point not available. - /// Status.Error: Miscellaneous error occurred. - public static DisplayTopologyStatus[] ValidateDisplayGrids( - IGridTopology[] gridTopologies, - SetDisplayTopologyFlag flags = SetDisplayTopologyFlag.NoFlag) - { - using (var gridTopologiesByRef = ValueTypeArray.FromArray(gridTopologies.AsEnumerable())) - { - var statuses = - typeof(DisplayTopologyStatus).Instantiate().Repeat(gridTopologies.Length); - var status = - DelegateFactory.GetDelegate()(flags, - gridTopologiesByRef, - ref statuses, (uint) gridTopologies.Length); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return statuses; - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoActivationFlag.cs b/app/NvAPIWrapper/Native/Stereo/StereoActivationFlag.cs deleted file mode 100644 index 2eb00540..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoActivationFlag.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid values for the stereo activation process - /// - public enum StereoActivationFlag - { - /// - /// Immediate activation - /// - Immediate = 0, - - /// - /// Delayed activation - /// - Delayed - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoActiveEye.cs b/app/NvAPIWrapper/Native/Stereo/StereoActiveEye.cs deleted file mode 100644 index eb143753..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoActiveEye.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid values for back buffer mode - /// - public enum StereoActiveEye - { - /// - /// No back buffer - /// - None = 0, - - /// - /// Right eye back buffer mode - /// - RightEye = 1, - - /// - /// Left eye back buffer mode - /// - LeftEye = 2, - - /// - /// Mono back buffer mode - /// - Mono = 3 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoDriverMode.cs b/app/NvAPIWrapper/Native/Stereo/StereoDriverMode.cs deleted file mode 100644 index e6c5c4cc..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoDriverMode.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of possible values for the driver stereo mode - /// - public enum StereoDriverMode - { - /// - /// Automatic stereo mode - /// - Automatic = 0, - - /// - /// Direct stereo mode - /// - Direct = 2 - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoFrustumAdjustMode.cs b/app/NvAPIWrapper/Native/Stereo/StereoFrustumAdjustMode.cs deleted file mode 100644 index 4c21faff..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoFrustumAdjustMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid frustum adjust modes - /// - public enum StereoFrustumAdjustMode - { - /// - /// No frustum adjustment - /// - NoFrustumAdjust, - - /// - /// Stretch frustum adjustment - /// - Stretch, - - /// - /// Clear edges frustum adjustment - /// - ClearEdges - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoRegistryIdentification.cs b/app/NvAPIWrapper/Native/Stereo/StereoRegistryIdentification.cs deleted file mode 100644 index 9072a071..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoRegistryIdentification.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid identification for registry values - /// - public enum StereoRegistryIdentification - { - /// - /// Convergence value identification - /// - Convergence, - - /// - /// Frustum adjust mode value identification - /// - FrustumAdjustMode - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoRegistryProfileType.cs b/app/NvAPIWrapper/Native/Stereo/StereoRegistryProfileType.cs deleted file mode 100644 index 36edfa5f..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoRegistryProfileType.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid application configuration registry profiles - /// - public enum StereoRegistryProfileType - { - /// - /// The default profile - /// - DefaultProfile, - - /// - /// The DirectX 9 specific profile - /// - DirectX9Profile, - - /// - /// The DirectX 10 specific profile - /// - DirectX10Profile - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoSurfaceCreateMode.cs b/app/NvAPIWrapper/Native/Stereo/StereoSurfaceCreateMode.cs deleted file mode 100644 index f9c284f2..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoSurfaceCreateMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid values for the stereo surface creation mode - /// - public enum StereoSurfaceCreateMode - { - /// - /// Automatic surface creation - /// - Auto = 0, - - /// - /// Force stereo surface creation - /// - ForceStereo, - - /// - /// Force mono surface creation - /// - ForceMono - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/StereoSwapChainMode.cs b/app/NvAPIWrapper/Native/Stereo/StereoSwapChainMode.cs deleted file mode 100644 index 745f64d0..00000000 --- a/app/NvAPIWrapper/Native/Stereo/StereoSwapChainMode.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace NvAPIWrapper.Native.Stereo -{ - /// - /// Holds a list of valid flags for the swap chain mode - /// - public enum StereoSwapChainMode - { - /// - /// Automatic - /// - Default = 0, - - /// - /// Stereo - /// - Stereo, - - /// - /// Mono - /// - Mono - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/Structures/StereoCapabilities.cs b/app/NvAPIWrapper/Native/Stereo/Structures/StereoCapabilities.cs deleted file mode 100644 index a70a1790..00000000 --- a/app/NvAPIWrapper/Native/Stereo/Structures/StereoCapabilities.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Attributes; -using NvAPIWrapper.Native.General.Structures; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Stereo.Structures -{ - /// - /// Holds information regarding the stereo capabilities of a monitor - /// - [StructLayout(LayoutKind.Sequential, Pack = 8)] - [StructureVersion(1)] - public struct StereoCapabilitiesV1 : IInitializable - { - internal StructureVersion _Version; - internal uint _Flags; - internal uint _Reserved1; - internal uint _Reserved2; - internal uint _Reserved3; - - /// - /// Gets a boolean value indicating if no windowed mode is supported - /// - public bool IsNoWindowedModeSupported - { - get => _Flags.GetBit(0); - } - - /// - /// Gets a boolean value indicating if automatic windowed mode is supported - /// - public bool IsAutomaticWindowedModeSupported - { - get => _Flags.GetBit(1); - } - - /// - /// Gets a boolean value indicating if the persistent windowed mode is supported - /// - public bool IsPersistentWindowedModeSupported - { - get => _Flags.GetBit(2); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/Stereo/Structures/StereoHandle.cs b/app/NvAPIWrapper/Native/Stereo/Structures/StereoHandle.cs deleted file mode 100644 index f19ec2c3..00000000 --- a/app/NvAPIWrapper/Native/Stereo/Structures/StereoHandle.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Interfaces; - -namespace NvAPIWrapper.Native.Stereo.Structures -{ - /// - /// Holds a handle representing a Device Stereo Session - /// - [StructLayout(LayoutKind.Sequential)] - public struct StereoHandle : IHandle, IEquatable - { - internal readonly IntPtr _MemoryAddress; - - /// - public bool Equals(StereoHandle other) - { - return _MemoryAddress.Equals(other._MemoryAddress); - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - - return obj is StereoHandle handle && Equals(handle); - } - - /// - public override int GetHashCode() - { - return _MemoryAddress.GetHashCode(); - } - - - /// - public override string ToString() - { - return $"StereoHandle #{MemoryAddress.ToInt64()}"; - } - - /// - public IntPtr MemoryAddress - { - get => _MemoryAddress; - } - - /// - public bool IsNull - { - get => _MemoryAddress == IntPtr.Zero; - } - - /// - /// Checks for equality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are equal, otherwise false - public static bool operator ==(StereoHandle left, StereoHandle right) - { - return left.Equals(right); - } - - /// - /// Checks for inequality between two objects of same type - /// - /// The first object - /// The second object - /// true, if both objects are not equal, otherwise false - public static bool operator !=(StereoHandle left, StereoHandle right) - { - return !left.Equals(right); - } - - /// - /// Gets default StereoHandle with a null pointer - /// - public static StereoHandle DefaultHandle - { - get => default(StereoHandle); - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/Native/StereoApi.cs b/app/NvAPIWrapper/Native/StereoApi.cs deleted file mode 100644 index 69fbff11..00000000 --- a/app/NvAPIWrapper/Native/StereoApi.cs +++ /dev/null @@ -1,899 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using NvAPIWrapper.Native.Exceptions; -using NvAPIWrapper.Native.General; -using NvAPIWrapper.Native.Helpers; -using NvAPIWrapper.Native.Helpers.Structures; -using NvAPIWrapper.Native.Stereo; -using NvAPIWrapper.Native.Stereo.Structures; - -namespace NvAPIWrapper.Native -{ - /// - /// Contains Stereo static functions - /// - // ReSharper disable once ClassTooBig - public static class StereoApi - { - /// - /// This API activates stereo for the device interface corresponding to the given stereo handle. - /// Activating stereo is possible only if stereo was enabled previously in the registry. - /// If stereo is not activated, then calls to functions that require that stereo is activated have no effect, - /// and will return the appropriate error code. - /// - /// Stereo handle corresponding to the device interface. - public static void ActivateStereo(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API captures the current stereo image in JPEG stereo format with the given quality. - /// Only the last capture call per flip will be effective. - /// - /// Stereo handle that corresponds to the device interface. - /// Quality of the JPEG image to be captured. Integer value between 0 and 100. - public static void CaptureJpegImage(StereoHandle handle, uint quality) - { - var status = DelegateFactory.GetDelegate()( - handle, - quality - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API captures the current stereo image in PNG stereo format. - /// Only the last capture call per flip will be effective. - /// - /// Stereo handle that corresponds to the device interface. - public static void CapturePngImage(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// Creates new configuration registry key for current application. - /// If there is no configuration profile prior to the function call, - /// this API tries to create a new configuration profile registry key - /// for a given application and fill it with the default values. - /// If an application already has a configuration profile registry key, the API does nothing. - /// The name of the key is automatically set to the name of the executable that calls this function. - /// Because of this, the executable should have a distinct and unique name. - /// If the application is using only one version of DirectX, then the default profile type will be appropriate. - /// If the application is using more than one version of DirectX from the same executable, - /// it should use the appropriate profile type for each configuration profile. - /// - /// Type of profile the application wants to create. - public static void CreateConfigurationProfileRegistryKey( - StereoRegistryProfileType registryProfileType) - { - var status = DelegateFactory - .GetDelegate()( - registryProfileType - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API creates a stereo handle that is used in subsequent calls related to a given device interface. - /// This must be called before any other NvAPI_Stereo_ function for that handle. - /// Multiple devices can be used at one time using multiple calls to this function (one per each device). - /// HOW TO USE: After the Direct3D device is created, create the stereo handle. - /// On call success: - /// -# Use all other functions that have stereo handle as first parameter. - /// -# After the device interface that corresponds to the the stereo handle is destroyed, - /// the application should call NvAPI_DestroyStereoHandle() for that stereo handle. - /// - /// Pointer to IUnknown interface that is IDirect3DDevice9* in DX9, ID3D10Device*. - /// Newly created stereo handle. - // ReSharper disable once InconsistentNaming - public static StereoHandle CreateHandleFromIUnknown(IntPtr d3dDevice) - { - var status = DelegateFactory.GetDelegate()( - d3dDevice, - out var stereoHandle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return stereoHandle; - } - - // ReSharper disable once CommentTypo - /// - /// This API allows the user to create a mono or a stereo swap chain. - /// NOTE: NvAPI_D3D1x_CreateSwapChain is a wrapper of the method IDXGIFactory::CreateSwapChain which - /// additionally notifies the D3D driver of the mode in which the swap chain is to be - /// created. - /// - /// - /// Stereo handle that corresponds to the device interface. The device that will write 2D images to - /// the swap chain. - /// - /// - /// A pointer to the swap-chain description (DXGI_SWAP_CHAIN_DESC). This parameter - /// cannot be NULL. - /// - /// The stereo mode fot the swap chain. - /// A pointer to the swap chain created. - public static IntPtr D3D1XCreateSwapChain( - StereoHandle handle, - IntPtr dxgiSwapChainDescription, - StereoSwapChainMode swapChainMode) - { - var status = DelegateFactory.GetDelegate()( - handle, - dxgiSwapChainDescription, - out var dxgiSwapChain, - swapChainMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return dxgiSwapChain; - } - - /// - /// This API allows the user to create a mono or a stereo swap chain. - /// NOTE: NvAPI_D3D9_CreateSwapChain is a wrapper of the method IDirect3DDevice9::CreateAdditionalSwapChain which - /// additionally notifies the D3D driver if the swap chain creation mode must be stereo or mono. - /// - /// Stereo handle that corresponds to the device interface. - /// A pointer to the swap-chain description (DXGI). This parameter cannot be NULL. - /// The stereo mode for the swap chain. - /// A pointer to the swap chain created. - public static IntPtr D3D9CreateSwapChain( - StereoHandle handle, - // ReSharper disable once InconsistentNaming - IntPtr d3dPresentParameters, - StereoSwapChainMode swapChainMode) - { - var status = DelegateFactory.GetDelegate()( - handle, - d3dPresentParameters, - out var direct3DSwapChain9, - swapChainMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return direct3DSwapChain9; - } - - /// - /// This API deactivates stereo for the given device interface. - /// If stereo is not activated, then calls to functions that require that stereo is activated have no effect, - /// and will return the appropriate error code. - /// - /// Stereo handle that corresponds to the device interface. - public static void DeactivateStereo(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API decreases convergence for the given device interface (just like the Ctrl+F5 hot-key). - /// - /// Stereo handle that corresponds to the device interface. - public static void DecreaseConvergence(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API decreases separation for the given device interface (just like the Ctrl+F3 hot-key). - /// - /// Stereo handle that corresponds to the device interface. - public static void DecreaseSeparation(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// Removes configuration registry key for current application. - /// If an application already has a configuration profile prior to this function call, - /// the function attempts to remove the application's configuration profile registry key from the registry. - /// If there is no configuration profile registry key prior to the function call, - /// the function does nothing and does not report an error. - /// - /// Type of profile that the application wants to delete. - public static void DeleteConfigurationProfileRegistryKey( - StereoRegistryProfileType registryProfileType) - { - var status = DelegateFactory - .GetDelegate()( - registryProfileType - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API removes the given value from the application's configuration profile registry key. - /// If there is no such value, the function does nothing and does not report an error. - /// - /// The type of profile the application wants to access. - /// ID of the value that is being deleted. - public static void DeleteConfigurationProfileValue( - StereoRegistryProfileType registryProfileType, - StereoRegistryIdentification registryId) - { - var status = DelegateFactory.GetDelegate()( - registryProfileType, - registryId - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API destroys the stereo handle created with one of the NvAPI_Stereo_CreateHandleFrom() functions. - /// This should be called after the device corresponding to the handle has been destroyed. - /// - /// Stereo handle that is to be destroyed. - public static void DestroyHandle(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API disables stereo mode in the registry. - /// Calls to this function affect the entire system. - /// If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect, - /// and will return the appropriate error code. - /// - public static void DisableStereo() - { - var status = DelegateFactory.GetDelegate()(); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This APU enables stereo mode in the registry. - /// Calls to this function affect the entire system. - /// If stereo is not enabled, then calls to functions that require that stereo is enabled have no effect, - /// and will return the appropriate error code. - /// - public static void EnableStereo() - { - var status = DelegateFactory.GetDelegate()(); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API gets the current convergence value. - /// - /// Stereo handle that corresponds to the device interface. - /// Current convergence value - public static float GetConvergence(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var convergence - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return convergence; - } - - /// - /// This API retrieves the current default stereo profile. - /// - /// Default stereo profile name. - public static string GetDefaultProfile() - { - var stringCapacity = 256; - var stringAddress = Marshal.AllocHGlobal(stringCapacity); - - try - { - var status = DelegateFactory.GetDelegate()( - (uint) stringCapacity, - stringAddress, - out var stringSize - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - if (stringSize == 0) - { - return null; - } - - return Marshal.PtrToStringAnsi(stringAddress, (int) stringSize); - } - finally - { - Marshal.FreeHGlobal(stringAddress); - } - } - - /// - /// This API returns eye separation as a ratio of [between eye distance]/[physical screen width]. - /// - /// Stereo handle that corresponds to the device interface. - /// Eye separation - public static float GetEyeSeparation(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var eyeSeparation - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return eyeSeparation; - } - - /// - /// This API gets the current frustum adjust mode value. - /// - /// Stereo handle that corresponds to the device interface. - /// Current frustum value - public static StereoFrustumAdjustMode GetFrustumAdjustMode(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var frustumAdjustMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return frustumAdjustMode; - } - - /// - /// This API gets current separation value (in percents). - /// - /// Stereo handle that corresponds to the device interface. - /// Current separation percentage - public static float GetSeparation(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var separationPercentage - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return separationPercentage; - } - - /// - /// This API checks what kind of stereo support is currently supported on a particular display. - /// If the the display is prohibited from showing stereo (e.g. secondary in a multi-mon setup), we will - /// return 0 for all stereo modes (full screen exclusive, automatic windowed, persistent windowed). - /// Otherwise, we will check which stereo mode is supported. On 120Hz display, this will be what - /// the user chooses in control panel. On HDMI 1.4 display, persistent windowed mode is always assumed to be - /// supported. Note that this function does not check if the CURRENT RESOLUTION/REFRESH RATE can support - /// stereo. For HDMI 1.4, it is the application's responsibility to change the resolution/refresh rate to one that is - /// 3D compatible. For 120Hz, the driver will ALWAYS force 120Hz anyway. - /// - /// Monitor that app is going to run on - /// An instance of structure. - public static StereoCapabilitiesV1 GetStereoSupport(IntPtr monitorHandle) - { - var instance = typeof(StereoCapabilitiesV1).Instantiate(); - - using (var reference = ValueTypeReference.FromValueType(instance)) - { - var status = DelegateFactory.GetDelegate()( - monitorHandle, - reference - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return reference.ToValueType(typeof(StereoCapabilitiesV1)); - } - } - - /// - /// This API gets surface creation mode for this device interface. - /// - /// Stereo handle that corresponds to the device interface. - /// The current creation mode for this device interface. - public static StereoSurfaceCreateMode GetSurfaceCreationMode(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var surfaceCreateMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return surfaceCreateMode; - } - - /// - /// This API increases convergence for given the device interface (just like the Ctrl+F6 hot-key). - /// - /// Stereo handle that corresponds to the device interface. - public static void IncreaseConvergence(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API increases separation for the given device interface (just like the Ctrl+F4 hot-key). - /// - /// Stereo handle that corresponds to the device interface. - public static void IncreaseSeparation(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API allows an application to enable stereo viewing, without the need of a GUID/Key pair - /// This API cannot be used to enable stereo viewing on 3DTV. - /// HOW TO USE: Call this function immediately after device creation, then follow with a reset. \n - /// Very generically: - /// Create Device->Create Stereo Handle->InitActivation->Reset Device - /// - /// Stereo handle corresponding to the device interface. - /// Flags to enable or disable delayed activation. - public static void InitActivation(StereoHandle handle, StereoActivationFlag activationFlag) - { - var status = DelegateFactory.GetDelegate()( - handle, - activationFlag - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API checks if stereo is activated for the given device interface. - /// - /// Stereo handle that corresponds to the device interface. - /// Address where result of the inquiry will be placed. - public static bool IsStereoActivated(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var isStereoActive - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return isStereoActive > 0; - } - - /// - /// This API checks if stereo mode is enabled in the registry. - /// - /// true if the stereo is enable; otherwise false - public static bool IsStereoEnabled() - { - var status = DelegateFactory.GetDelegate()( - out var isEnable - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return isEnable > 0; - } - - /// - /// This API returns availability of windowed mode stereo - /// - /// true if windowed mode is supported; otherwise false - public static bool IsWindowedModeSupported() - { - var status = DelegateFactory.GetDelegate()( - out var supported - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return supported > 0; - } - - /// - /// This API turns on/off reverse stereo blit. - /// After reversed stereo blit control is turned on, blits from the stereo surface will - /// produce the right-eye image in the left side of the destination surface and the left-eye - /// image in the right side of the destination surface. - /// In DirectX 9, the destination surface must be created as the render target, and StretchRect must be used. - /// Conditions: - /// - DstWidth == 2*SrcWidth - /// - DstHeight == SrcHeight - /// - Src surface is the stereo surface. - /// - SrcRect must be {0,0,SrcWidth,SrcHeight} - /// - DstRect must be {0,0,DstWidth,DstHeight} - /// In DirectX 10, ResourceCopyRegion must be used. - /// Conditions: - /// - DstWidth == 2*SrcWidth - /// - DstHeight == SrcHeight - /// - dstX == 0, - /// - dstY == 0, - /// - dstZ == 0, - /// - SrcBox: left=top=front==0; right==SrcWidth; bottom==SrcHeight; back==1; - /// - /// Stereo handle corresponding to the device interface. - /// A boolean value to enable or disable blit control - public static void ReverseStereoBlitControl(StereoHandle handle, bool turnOn) - { - var status = DelegateFactory.GetDelegate()( - handle, - (byte) (turnOn ? 1 : 0) - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the back buffer to left or right in Direct stereo mode. - /// - /// Stereo handle that corresponds to the device interface. - /// Defines active eye in Direct stereo mode - public static void SetActiveEye(StereoHandle handle, StereoActiveEye activeEye) - { - var status = DelegateFactory.GetDelegate()( - handle, - activeEye - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the given parameter value under the application's registry key. - /// If the value does not exist under the application's registry key, the value will be created under the key. - /// - /// The type of profile the application wants to access. - /// ID of the value that is being set. - /// Value that is being set. - public static void SetConfigurationProfileValue( - StereoRegistryProfileType registryProfileType, - StereoRegistryIdentification registryId, - float value) - { - var status = DelegateFactory.GetDelegate()( - registryProfileType, - registryId, - ref value - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the given parameter value under the application's registry key. - /// If the value does not exist under the application's registry key, the value will be created under the key. - /// - /// The type of profile the application wants to access. - /// ID of the value that is being set. - /// Value that is being set. - public static void SetConfigurationProfileValue( - StereoRegistryProfileType registryProfileType, - StereoRegistryIdentification registryId, - int value) - { - var status = - DelegateFactory.GetDelegate()( - registryProfileType, - registryId, - ref value - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets convergence to the given value. - /// - /// Stereo handle that corresponds to the device interface. - /// New value for convergence. - public static void SetConvergence(StereoHandle handle, float convergence) - { - var status = DelegateFactory.GetDelegate()( - handle, - convergence - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API defines the stereo profile used by the driver in case the application has no associated profile. - /// To take effect, this API must be called before D3D device is created. Calling once a device has been created will - /// not affect the current device. - /// - /// Default profile name. - public static void SetDefaultProfile(string profileName) - { - var status = DelegateFactory.GetDelegate()( - profileName - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the 3D stereo driver mode: Direct or Automatic - /// - /// Defines the 3D stereo driver mode: Direct or Automatic - public static void SetDriverMode(StereoDriverMode driverMode) - { - var status = DelegateFactory.GetDelegate()( - driverMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets the current frustum adjust mode value. - /// - /// Stereo handle that corresponds to the device interface. - /// New value for frustum adjust mode. - public static void SetFrustumAdjustMode( - StereoHandle handle, - StereoFrustumAdjustMode frustumAdjustMode) - { - var status = DelegateFactory.GetDelegate()( - handle, - frustumAdjustMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API checks if the last draw call was stereoized. It is a very expensive to call and should be used for - /// debugging purpose *only*. - /// - /// Stereo handle that corresponds to the device interface. - /// true if the last draw was a stereo draw; otherwise false - public static bool WasLastDrawStereoizedDebug(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle, - out var supported - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - - return supported > 0; - } // ReSharper disable CommentTypo - /// - /// This API is a Setup notification message that the stereo driver uses to notify the application - /// when the user changes the stereo driver state. - /// When the user changes the stereo state (Activated or Deactivated, separation or conversion) - /// the stereo driver posts a defined message with the following parameters: - /// lParam is the current conversion. (Actual conversion is *(float*)&lParam ) - /// wParam == MAKEWPARAM(l, h) where - /// - l == 0 if stereo is deactivated - /// - l == 1 if stereo is deactivated - /// - h is the current separation. (Actual separation is float(h*100.f/0xFFFF) - /// Call this API with NULL hWnd to prohibit notification. - /// - /// Stereo handle corresponding to the device interface. - /// - /// Window handle that will be notified when the user changes the stereo driver state. Actual - /// handle must be cast to an . - /// - /// MessageID of the message that will be posted to window - public static void SetNotificationMessage( - StereoHandle handle, - ulong windowsHandle, - ulong messageId) - { - var status = DelegateFactory.GetDelegate()( - handle, - windowsHandle, - messageId - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets separation to given percentage. - /// - /// Stereo handle that corresponds to the device interface. - /// New value for separation percentage. - public static void SetSeparation(StereoHandle handle, float separationPercentage) - { - var status = DelegateFactory.GetDelegate()( - handle, - separationPercentage - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API sets surface creation mode for this device interface. - /// - /// Stereo handle that corresponds to the device interface. - /// New surface creation mode for this device interface. - public static void SetSurfaceCreationMode( - StereoHandle handle, - StereoSurfaceCreateMode surfaceCreateMode) - { - var status = DelegateFactory.GetDelegate()( - handle, - surfaceCreateMode - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - - /// - /// This API allows an application to trigger creation of a stereo desktop, - /// in case the creation was stopped on application launch. - /// - /// Stereo handle that corresponds to the device interface. - public static void TriggerActivation(StereoHandle handle) - { - var status = DelegateFactory.GetDelegate()( - handle - ); - - if (status != Status.Ok) - { - throw new NVIDIAApiException(status); - } - } - } -} \ No newline at end of file diff --git a/app/NvAPIWrapper/NvAPIWrapper.csproj b/app/NvAPIWrapper/NvAPIWrapper.csproj deleted file mode 100644 index 2a854c24..00000000 --- a/app/NvAPIWrapper/NvAPIWrapper.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - netstandard2.0;net45 - 0.8.1.101 - falahati.net - NvAPIWrapper is a .Net wrapper for NVIDIA public API - Soroush Falahati - Copyright © Soroush Falahati 2018 (falahati.net) - AnyCPU - NvAPIWrapper.Net - https://github.com/falahati/NvAPIWrapper - https://github.com/falahati/NvAPIWrapper/blob/master/LICENSE - https://github.com/falahati/NvAPIWrapper/blob/master/NvAPIWrapper/Icon.png?raw=true - true - true - AnyCPU - NvAPIWrapper (for NVAPI 410) - NvAPIWrapper.Net - OpenSourceStrongNameSignKey.pfx - - - ..\Debug - - - True - true - ..\Release - ..\Release\NvAPIWrapper.xml - true - - - - all - runtime; build; native; contentfiles; analyzers - - - - - true - \ - - - true - \ - - - - - - \ No newline at end of file diff --git a/app/NvAPIWrapper/readme.txt b/app/NvAPIWrapper/readme.txt deleted file mode 100644 index 211a58ca..00000000 --- a/app/NvAPIWrapper/readme.txt +++ /dev/null @@ -1,12 +0,0 @@ - NvAPIWrapper Library ------------------------------------------------------------- -NvAPIWrapper is a library released under the LGPLv3 license, -allowing all .Net developers to access and use the NVAPI -functionalities. - -For more information about this library, please check out -our GitHub page: -https://github.com/falahati/NvAPIWrapper - - -2017 Soroush Falahati (https://falahati.net) \ No newline at end of file diff --git a/app/Program.cs b/app/Program.cs index 6b5e96b7..ecb89fab 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -1,9 +1,15 @@ +using GHelper.Gpu; +using GHelper.Helpers; +using GHelper.Input; +using GHelper.Mode; +using GHelper.Display; using Microsoft.Win32; using Ryzen; using System.Diagnostics; using System.Globalization; using System.Reflection; using static NativeMethods; +using GHelper.AutoUpdate; namespace GHelper { @@ -17,16 +23,22 @@ namespace GHelper Visible = true }; - public static AsusACPI? acpi; + public static AsusACPI acpi; public static SettingsForm settingsForm = new SettingsForm(); + public static ModeControl modeControl = new ModeControl(); + static GPUModeControl gpuControl = new GPUModeControl(settingsForm); + static ScreenControl screenControl = new ScreenControl(); + + public static ToastForm toast = new ToastForm(); + public static IntPtr unRegPowerNotify; private static long lastAuto; private static long lastTheme; - public static InputDispatcher inputDispatcher; + public static InputDispatcher? inputDispatcher; private static PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus; @@ -48,8 +60,6 @@ namespace GHelper Thread.CurrentThread.CurrentUICulture = culture; } - Debug.WriteLine(CultureInfo.CurrentUICulture); - ProcessHelper.CheckAlreadyRunning(); try @@ -74,9 +84,7 @@ namespace GHelper Application.EnableVisualStyles(); HardwareControl.RecreateGpuControl(); - Undervolter.Init(); - - var ds = settingsForm.Handle; + RyzenControl.Init(); trayIcon.MouseClick += TrayIcon_MouseClick; @@ -84,7 +92,6 @@ namespace GHelper settingsForm.InitAura(); settingsForm.InitMatrix(); - settingsForm.SetStartupCheck(Startup.IsScheduled()); SetAutoModes(); @@ -95,7 +102,7 @@ namespace GHelper // Subscribing for monitor power on events PowerSettingGuid settingGuid = new NativeMethods.PowerSettingGuid(); - unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); + unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(settingsForm.Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0) @@ -151,14 +158,14 @@ namespace GHelper inputDispatcher.Init(); settingsForm.SetBatteryChargeLimit(AppConfig.Get("charge_limit")); - settingsForm.AutoPerformance(powerChanged); + modeControl.AutoPerformance(powerChanged); - bool switched = settingsForm.AutoGPUMode(); + bool switched = gpuControl.AutoGPUMode(); if (!switched) { - settingsForm.InitGPUMode(); - settingsForm.AutoScreen(); + gpuControl.InitGPUMode(); + screenControl.AutoScreen(); } settingsForm.AutoKeyboard(); @@ -193,12 +200,16 @@ namespace GHelper switch (action) { + case "cpu": + Startup.ReScheduleAdmin(); + settingsForm.FansToggle(); + break; case "gpu": Startup.ReScheduleAdmin(); settingsForm.FansToggle(1); break; case "gpurestart": - settingsForm.RestartGPU(false); + gpuControl.RestartGPU(false); break; case "services": settingsForm.keyb = new Extra(); @@ -208,7 +219,7 @@ namespace GHelper case "uv": Startup.ReScheduleAdmin(); settingsForm.FansToggle(2); - settingsForm.SetUV(); + modeControl.SetRyzen(); break; } } @@ -217,9 +228,7 @@ namespace GHelper static void TrayIcon_MouseClick(object? sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) - { SettingsToggle(); - } } diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index 1ff1f7f4..ad98aea2 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -390,6 +390,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_refresh_32 { + get { + object obj = ResourceManager.GetObject("icons8-refresh-32", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index 92c3e9fb..4687e7d4 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -118,9 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\brightness-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -169,6 +166,9 @@ ..\Resources\icons8-spa-flower-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-edit-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-share-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -181,6 +181,9 @@ ..\Resources\icons8-voltage-60.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\backlight-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-keyboard-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -202,15 +205,12 @@ ..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-charging-battery-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-edit-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\backlight-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -253,8 +253,8 @@ ..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\backlight-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-boost-30.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -268,4 +268,7 @@ ..\Resources\icons8-temperature-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-refresh-32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 3be60002..e5ba1ab9 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -160,7 +160,7 @@ namespace GHelper.Properties { } /// - /// Looks up a localized string similar to Apply. + /// Looks up a localized string similar to Apply Power Limits. /// internal static string ApplyPowerLimits { get { @@ -456,6 +456,26 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Disabling the dGPU by going to Eco mode while Display Mode in NVIDIA Control Panel is not set to Optimus might cause problems with brightness controls until after the next reboot. + /// + ///Do you still want to continue?. + /// + internal static string EnableOptimusText { + get { + return ResourceManager.GetString("EnableOptimusText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to NVIDIA Display Mode is not set to Optimus. + /// + internal static string EnableOptimusTitle { + get { + return ResourceManager.GetString("EnableOptimusTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Extra. /// @@ -861,6 +881,24 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to New updates. + /// + internal static string NewUpdates { + get { + return ResourceManager.GetString("NewUpdates", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No new updates. + /// + internal static string NoNewUpdates { + get { + return ResourceManager.GetString("NoNewUpdates", resourceCulture); + } + } + /// /// Looks up a localized string similar to Open G-Helper window. /// @@ -1086,6 +1124,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Stop GPU Applications. + /// + internal static string StopGPUApps { + get { + return ResourceManager.GetString("StopGPUApps", resourceCulture); + } + } + /// /// Looks up a localized string similar to Stopping Services. /// @@ -1176,6 +1223,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Undervolting is experimental and risky feature. If applied values are too low for your hardware, it can become unstable, shut down or cause data corruption. If you want to try - start from small values first, click Apply and test what works for you.. + /// + internal static string UndervoltingRisky { + get { + return ResourceManager.GetString("UndervoltingRisky", resourceCulture); + } + } + /// /// Looks up a localized string similar to Updates. /// diff --git a/app/Properties/Strings.es.resx b/app/Properties/Strings.es.resx index 7e8cb729..f19bde5e 100644 --- a/app/Properties/Strings.es.resx +++ b/app/Properties/Strings.es.resx @@ -249,6 +249,14 @@ Eco + + Deshabilitar la dGPU cambiando a modo Eco moentras el Modo de Pantalla en el Panel de Control de NVIDIA no está configurado en Optimus puede causar problemas con el control del brillo hasta después del próximo reinicio. + +¿Seguro que desea continuar? + + + Modo de Pantalla NVIDIA no está configurado en Optimus + Adicional @@ -384,6 +392,12 @@ Silenciar micrófono + + Nuevas actualizaciones + + + No hay nuevas actualizaciones + Abrir ventana G-Helper @@ -403,7 +417,7 @@ Overdrive - Modo de rendimiento + Modo Imagen / Gif @@ -459,6 +473,9 @@ Detener + + Detener aplicaciones dGPU + Deteniendo servicios @@ -489,6 +506,9 @@ Ultimate + + Undervolting es una característica experimental. Aplicar valores demasiado bajos puede causar inestabilidad en el hardware o corrupción de datos. Si desea probar, empiece con valores pequeños, haga click en Aplicar y pruebe. + Actualización diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 3e0175d1..0a020801 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -249,6 +249,14 @@ Eco + + Disabling the dGPU by going to Eco mode while Display Mode in NVIDIA Control Panel is not set to Optimus might cause problems with brightness controls until after the next reboot. + +Do you still want to continue? + + + NVIDIA Display Mode is not set to Optimus + Extra @@ -384,6 +392,12 @@ Mute Mic + + New updates + + + No new updates + Open G-Helper window @@ -459,6 +473,9 @@ Stop + + Stop GPU Applications + Stopping Services @@ -489,6 +506,9 @@ Ultimate + + Undervolting is experimental and risky feature. If applied values are too low for your hardware, it can become unstable, shut down or cause data corruption. If you want to try - start from small values first, click Apply and test what works for you. + Updates diff --git a/app/Resources/icons8-refresh-32.png b/app/Resources/icons8-refresh-32.png new file mode 100644 index 00000000..241ba5c4 Binary files /dev/null and b/app/Resources/icons8-refresh-32.png differ diff --git a/app/Ryzen/Undervolter.cs b/app/Ryzen/RyzenControl.cs similarity index 97% rename from app/Ryzen/Undervolter.cs rename to app/Ryzen/RyzenControl.cs index 35dd7a95..0e942809 100644 --- a/app/Ryzen/Undervolter.cs +++ b/app/Ryzen/RyzenControl.cs @@ -8,7 +8,7 @@ using System.Management; namespace Ryzen { - internal class Undervolter + internal class RyzenControl { public const int MinCPUUV = -30; @@ -126,11 +126,14 @@ namespace Ryzen public static bool IsAMD() { - if (CPUName.Length == 0) Init(); - return CPUName.Contains("AMD") || CPUName.Contains("Ryzen") || CPUName.Contains("Athlon") || CPUName.Contains("Radeon") || CPUName.Contains("AMD Custom APU 0405"); + } + public static bool IsRyzen9() + { + if (CPUName.Length == 0) Init(); + return CPUName.Contains("Ryzen 9"); } public static void SetAddresses() diff --git a/app/Ryzen/RyzenSmu.cs b/app/Ryzen/RyzenSmu.cs index d031f03c..8e8ab45f 100644 --- a/app/Ryzen/RyzenSmu.cs +++ b/app/Ryzen/RyzenSmu.cs @@ -135,12 +135,16 @@ namespace Ryzen public Status SendMp1(uint message, ref uint[] arguments) { - return SendMsg(MP1_ADDR_MSG, MP1_ADDR_RSP, MP1_ADDR_ARG, message, ref arguments); + var result = SendMsg(MP1_ADDR_MSG, MP1_ADDR_RSP, MP1_ADDR_ARG, message, ref arguments); + //Logger.WriteLine($"RyzenMP1:{message} {arguments[0]} {result}"); + return result; } public Status SendPsmu(uint message, ref uint[] arguments) { - return SendMsg(PSMU_ADDR_MSG, PSMU_ADDR_RSP, PSMU_ADDR_ARG, message, ref arguments); + var result = SendMsg(PSMU_ADDR_MSG, PSMU_ADDR_RSP, PSMU_ADDR_ARG, message, ref arguments); + //Logger.WriteLine($"RyzenPSMU:{message} {arguments[0]} {result}"); + return result; } diff --git a/app/Ryzen/SendCommand.cs b/app/Ryzen/SendCommand.cs index 77be8411..f59a28e4 100644 --- a/app/Ryzen/SendCommand.cs +++ b/app/Ryzen/SendCommand.cs @@ -22,7 +22,7 @@ namespace Ryzen //RAPHAEL/DRAGON RANGE - 10 public static Smu RyzenAccess = new Smu(false); - public static int FAMID = Undervolter.FAMID; + public static int FAMID = RyzenControl.FAMID; //STAMP Limit @@ -189,7 +189,7 @@ namespace Ryzen } //TCTL Temp Limit - public static void set_tctl_temp(uint value) + public static Smu.Status? set_tctl_temp(uint value) { RyzenAccess.Initialize(); uint[] Args = new uint[6]; @@ -227,9 +227,8 @@ namespace Ryzen break; } - Logger.WriteLine($"CPU Temp: {value} {result}"); - RyzenAccess.Deinitialize(); + return result; } //cHTC Temp Limit @@ -261,7 +260,7 @@ namespace Ryzen } //Skin Temp limit - public static void set_apu_skin_temp_limit(uint value) + public static Smu.Status? set_apu_skin_temp_limit(uint value) { RyzenAccess.Initialize(); uint[] Args = new uint[6]; @@ -285,9 +284,9 @@ namespace Ryzen break; } - Logger.WriteLine($"APU Temp: {value} {result}"); - RyzenAccess.Deinitialize(); + + return result; } //VRM Current @@ -908,7 +907,7 @@ namespace Ryzen } //Set All Core Curve Optimiser - public static void set_coall(int value) + public static Smu.Status? set_coall(int value) { uint uvalue = Convert.ToUInt32(0x100000 - (uint)(-1 * value)); @@ -944,9 +943,9 @@ namespace Ryzen break; } - Logger.WriteLine($"UV: {value} {result}"); - RyzenAccess.Deinitialize(); + return result; + } //Set Per Core Curve Optimiser @@ -982,7 +981,7 @@ namespace Ryzen } //Set iGPU Curve Optimiser - public static void set_cogfx(int value) + public static Smu.Status? set_cogfx(int value) { uint uvalue = Convert.ToUInt32(0x100000 - (uint)(-1 * value)); @@ -1010,9 +1009,8 @@ namespace Ryzen break; } - Logger.WriteLine($"iGPU UV: {value} {result}"); - RyzenAccess.Deinitialize(); + return result; } //Disable OC diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 88307144..37ae0ea8 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -1,4 +1,4 @@ -using CustomControls; +using GHelper.UI; namespace GHelper { @@ -41,7 +41,7 @@ namespace GHelper labelMatrix = new Label(); checkMatrix = new CheckBox(); panelBattery = new Panel(); - sliderBattery = new WinFormsSliderBar.Slider(); + sliderBattery = new Slider(); panelBatteryTitle = new Panel(); labelBattery = new Label(); pictureBattery = new PictureBox(); @@ -97,6 +97,7 @@ namespace GHelper labelVersion = new Label(); labelModel = new Label(); panelVersion = new Panel(); + buttonStopGPU = new RButton(); panelMatrix.SuspendLayout(); tableLayoutMatrix.SuspendLayout(); panelMatrixTitle.SuspendLayout(); @@ -592,6 +593,7 @@ namespace GHelper tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableGPU.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableGPU.Controls.Add(buttonStopGPU, 0, 0); tableGPU.Controls.Add(buttonEco, 0, 0); tableGPU.Controls.Add(buttonStandard, 1, 0); tableGPU.Controls.Add(buttonXGM, 2, 0); @@ -664,11 +666,11 @@ namespace GHelper buttonXGM.ForeColor = SystemColors.ControlText; buttonXGM.Image = Properties.Resources.icons8_video_48; buttonXGM.ImageAlign = ContentAlignment.BottomCenter; - buttonXGM.Location = new Point(4, 132); + buttonXGM.Location = new Point(580, 4); buttonXGM.Margin = new Padding(4); buttonXGM.Name = "buttonXGM"; buttonXGM.Secondary = false; - buttonXGM.Size = new Size(184, 120); + buttonXGM.Size = new Size(186, 120); buttonXGM.TabIndex = 2; buttonXGM.Text = "XG Mobile"; buttonXGM.TextImageRelation = TextImageRelation.ImageAboveText; @@ -687,11 +689,11 @@ namespace GHelper buttonOptimized.ForeColor = SystemColors.ControlText; buttonOptimized.Image = Properties.Resources.icons8_project_management_48__1_; buttonOptimized.ImageAlign = ContentAlignment.BottomCenter; - buttonOptimized.Location = new Point(580, 4); + buttonOptimized.Location = new Point(388, 4); buttonOptimized.Margin = new Padding(4); buttonOptimized.Name = "buttonOptimized"; buttonOptimized.Secondary = false; - buttonOptimized.Size = new Size(186, 120); + buttonOptimized.Size = new Size(184, 120); buttonOptimized.TabIndex = 3; buttonOptimized.Text = Properties.Strings.Optimized; buttonOptimized.TextImageRelation = TextImageRelation.ImageAboveText; @@ -709,7 +711,7 @@ namespace GHelper buttonUltimate.ForeColor = SystemColors.ControlText; buttonUltimate.Image = Properties.Resources.icons8_game_controller_48; buttonUltimate.ImageAlign = ContentAlignment.BottomCenter; - buttonUltimate.Location = new Point(388, 4); + buttonUltimate.Location = new Point(4, 132); buttonUltimate.Margin = new Padding(4); buttonUltimate.Name = "buttonUltimate"; buttonUltimate.Secondary = false; @@ -1118,6 +1120,30 @@ namespace GHelper panelVersion.Size = new Size(810, 57); panelVersion.TabIndex = 41; // + // buttonStopGPU + // + buttonStopGPU.Activated = false; + buttonStopGPU.BackColor = SystemColors.ControlLightLight; + buttonStopGPU.BorderColor = Color.Transparent; + buttonStopGPU.BorderRadius = 5; + buttonStopGPU.CausesValidation = false; + buttonStopGPU.Dock = DockStyle.Top; + buttonStopGPU.FlatAppearance.BorderSize = 0; + buttonStopGPU.FlatStyle = FlatStyle.Flat; + buttonStopGPU.ForeColor = SystemColors.ControlText; + buttonStopGPU.Image = Properties.Resources.icons8_leaf_48; + buttonStopGPU.ImageAlign = ContentAlignment.BottomCenter; + buttonStopGPU.Location = new Point(196, 132); + buttonStopGPU.Margin = new Padding(4); + buttonStopGPU.Name = "buttonStopGPU"; + buttonStopGPU.Secondary = false; + buttonStopGPU.Size = new Size(184, 120); + buttonStopGPU.TabIndex = 4; + buttonStopGPU.Text = "Stop GPU applications"; + buttonStopGPU.TextImageRelation = TextImageRelation.ImageAboveText; + buttonStopGPU.UseVisualStyleBackColor = false; + buttonStopGPU.Visible = false; + // // SettingsForm // AutoScaleDimensions = new SizeF(192F, 192F); @@ -1143,7 +1169,6 @@ namespace GHelper ShowIcon = false; StartPosition = FormStartPosition.CenterScreen; Text = "G-Helper"; - Load += Settings_Load; panelMatrix.ResumeLayout(false); panelMatrix.PerformLayout(); tableLayoutMatrix.ResumeLayout(false); @@ -1228,7 +1253,7 @@ namespace GHelper private RButton buttonKeyboard; private RButton buttonKeyboardColor; private RButton buttonFans; - private WinFormsSliderBar.Slider sliderBattery; + private Slider sliderBattery; private RButton buttonUpdates; private Panel panelGPUTitle; private PictureBox pictureGPU; @@ -1255,5 +1280,6 @@ namespace GHelper private Panel panelVersion; private Label labelVersion; private Label labelModel; + private RButton buttonStopGPU; } } \ No newline at end of file diff --git a/app/Settings.cs b/app/Settings.cs index a093405f..a5bf6dff 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1,11 +1,12 @@ -using CustomControls; -using GHelper.AnimeMatrix; +using GHelper.AnimeMatrix; +using GHelper.AutoUpdate; +using GHelper.Display; using GHelper.Gpu; -using Ryzen; +using GHelper.Helpers; +using GHelper.Input; +using GHelper.Mode; +using GHelper.UI; using System.Diagnostics; -using System.Net; -using System.Reflection; -using System.Text.Json; using System.Timers; namespace GHelper @@ -14,29 +15,23 @@ namespace GHelper public partial class SettingsForm : RForm { - private ContextMenuStrip contextMenuStrip = new CustomContextMenu(); - private ToolStripMenuItem menuSilent, menuBalanced, menuTurbo, menuEco, menuStandard, menuUltimate, menuOptimized; + ContextMenuStrip contextMenuStrip = new CustomContextMenu(); + ToolStripMenuItem menuSilent, menuBalanced, menuTurbo, menuEco, menuStandard, menuUltimate, menuOptimized; - public ToastForm toast = new ToastForm(); + GPUModeControl gpuControl; + ScreenControl screenControl = new ScreenControl(); + AutoUpdateControl updateControl; - public static System.Timers.Timer aTimer = default!; - public static Point trayPoint; + public AniMatrixControl matrix; - public string versionUrl = "http://github.com/seerge/g-helper/releases"; + public static System.Timers.Timer sensorTimer = default!; - public string modeName = "Balanced"; + public Fans? fans; + public Extra? keyb; + public Updates? updates; - public AniMatrix matrix; - public Fans fans; - public Extra keyb; - public Updates updates; - - static long lastUpdate; static long lastRefresh; - private bool customFans = false; - private int customPower = 0; - bool isGpuSection = true; public SettingsForm() @@ -45,6 +40,10 @@ namespace GHelper InitializeComponent(); InitTheme(true); + gpuControl = new GPUModeControl(this); + updateControl = new AutoUpdateControl(this); + matrix = new AniMatrixControl(this); + buttonSilent.Text = Properties.Strings.Silent; buttonBalanced.Text = Properties.Strings.Balanced; buttonTurbo.Text = Properties.Strings.Turbo; @@ -54,7 +53,7 @@ namespace GHelper buttonUltimate.Text = Properties.Strings.UltimateMode; buttonStandard.Text = Properties.Strings.StandardMode; buttonOptimized.Text = Properties.Strings.Optimized; - + buttonStopGPU.Text = Properties.Strings.StopGPUApps; buttonScreenAuto.Text = Properties.Strings.AutoMode; buttonMiniled.Text = Properties.Strings.Multizone; @@ -102,6 +101,7 @@ namespace GHelper buttonStandard.Click += ButtonStandard_Click; buttonUltimate.Click += ButtonUltimate_Click; buttonOptimized.Click += ButtonOptimized_Click; + buttonStopGPU.Click += ButtonStopGPU_Click; VisibleChanged += SettingsForm_VisibleChanged; @@ -131,6 +131,7 @@ namespace GHelper buttonMatrix.Click += ButtonMatrix_Click; + checkStartup.Checked = Startup.IsScheduled(); checkStartup.CheckedChanged += CheckStartup_CheckedChanged; labelVersion.Click += LabelVersion_Click; @@ -167,43 +168,25 @@ namespace GHelper sliderBattery.ValueChanged += SliderBattery_ValueChanged; Program.trayIcon.MouseMove += TrayIcon_MouseMove; - aTimer = new System.Timers.Timer(1000); - aTimer.Elapsed += OnTimedEvent; - aTimer.Enabled = true; - - SetVersionLabel(Properties.Strings.VersionLabel + ": " + Assembly.GetExecutingAssembly().GetName().Version); - - string model = AppConfig.GetModel(); - int trim = model.LastIndexOf("_"); - if (trim > 0) model = model.Substring(0, trim); - - labelModel.Text = model + (ProcessHelper.IsUserAdministrator() ? "." : ""); + sensorTimer = new System.Timers.Timer(1000); + sensorTimer.Elapsed += OnTimedEvent; + sensorTimer.Enabled = true; + labelModel.Text = AppConfig.GetModelShort() + (ProcessHelper.IsUserAdministrator() ? "." : ""); TopMost = AppConfig.Is("topmost"); SetContextMenu(); - } private void SettingsForm_VisibleChanged(object? sender, EventArgs e) { - aTimer.Enabled = this.Visible; + sensorTimer.Enabled = this.Visible; if (this.Visible) { - InitScreen(); - InitXGM(); - - // Run update once per 12 hours - if (Math.Abs(DateTimeOffset.Now.ToUnixTimeSeconds() - lastUpdate) < 43200) return; - lastUpdate = DateTimeOffset.Now.ToUnixTimeSeconds(); - - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(1)); - CheckForUpdatesAsync(); - }); - + screenControl.InitScreen(); + gpuControl.InitXGM(); + updateControl.CheckForUpdates(); } } @@ -258,11 +241,6 @@ namespace GHelper } } - public void RunToast(string text, ToastIcon? icon = null) - { - toast.RunToast(text, icon); - } - public void SetContextMenu() { @@ -348,47 +326,7 @@ namespace GHelper private void ButtonXGM_Click(object? sender, EventArgs e) { - - Task.Run(async () => - { - BeginInvoke(delegate - { - ButtonEnabled(buttonOptimized, false); - ButtonEnabled(buttonEco, false); - ButtonEnabled(buttonStandard, false); - ButtonEnabled(buttonUltimate, false); - ButtonEnabled(buttonXGM, false); - }); - - if (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1) - { - HardwareControl.KillGPUApps(); - DialogResult dialogResult = MessageBox.Show("Did you close all applications running on XG Mobile?", "Disabling XG Mobile", MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - { - Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM"); - await Task.Delay(TimeSpan.FromSeconds(15)); - } - } - else - { - Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM"); - AsusUSB.ApplyXGMLight(AppConfig.Is("xmg_light")); - - await Task.Delay(TimeSpan.FromSeconds(15)); - - if (AppConfig.IsMode("auto_apply")) - AsusUSB.SetXGMFan(AppConfig.GetFanConfig(AsusFan.XGM)); - } - - BeginInvoke(delegate - { - InitGPUMode(); - }); - - - }); - + gpuControl.ToggleXGM(); } private void SliderBattery_ValueChanged(object? sender, EventArgs e) @@ -397,112 +335,19 @@ namespace GHelper } - public async void CheckForUpdatesAsync() + public void SetVersionLabel(string label, bool update = false) { - - try - { - - using (var httpClient = new HttpClient()) - { - httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App"); - var json = await httpClient.GetStringAsync("https://api.github.com/repos/seerge/g-helper/releases/latest"); - var config = JsonSerializer.Deserialize(json); - var tag = config.GetProperty("tag_name").ToString().Replace("v", ""); - var assets = config.GetProperty("assets"); - - string url = null; - - for (int i = 0; i < assets.GetArrayLength(); i++) - { - if (assets[i].GetProperty("browser_download_url").ToString().Contains(".zip")) - url = assets[i].GetProperty("browser_download_url").ToString(); - } - - if (url is null) - url = assets[0].GetProperty("browser_download_url").ToString(); - - var gitVersion = new Version(tag); - var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); - //appVersion = new Version("0.50.0.0"); - - if (gitVersion.CompareTo(appVersion) > 0) - { - SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url); - if (AppConfig.GetString("skip_version") != tag) - { - DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - AutoUpdate(url); - else - AppConfig.Set("skip_version", tag); - } - - } - else - { - Debug.WriteLine("Latest version"); - } - - } - } - catch (Exception ex) - { - //Logger.WriteLine("Failed to check for updates:" + ex.Message); - - } - - } - - void SetVersionLabel(string label, string url = null) - { - BeginInvoke(delegate + Invoke(delegate { labelVersion.Text = label; - if (url is not null) - { - this.versionUrl = url; - labelVersion.ForeColor = Color.Red; - } + if (update) labelVersion.ForeColor = colorTurbo; }); - - } - - - public async void AutoUpdate(string requestUri) - { - - Uri uri = new Uri(requestUri); - string zipName = Path.GetFileName(uri.LocalPath); - - string exeLocation = Application.ExecutablePath; - string exeDir = Path.GetDirectoryName(exeLocation); - string zipLocation = exeDir + "\\" + zipName; - - using (WebClient client = new WebClient()) - { - client.DownloadFile(uri, zipLocation); - - Logger.WriteLine(requestUri); - Logger.WriteLine(zipLocation); - Logger.WriteLine(exeLocation); - - var cmd = new Process(); - cmd.StartInfo.UseShellExecute = false; - cmd.StartInfo.CreateNoWindow = true; - cmd.StartInfo.FileName = "powershell"; - cmd.StartInfo.Arguments = $"Start-Sleep -Seconds 1; Expand-Archive {zipLocation} -DestinationPath {exeDir} -Force; Remove-Item {zipLocation} -Force; {exeLocation}"; - cmd.Start(); - - Application.Exit(); - } - } private void LabelVersion_Click(object? sender, EventArgs e) { - Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true }); + updateControl.LoadReleases(); } private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e) @@ -578,14 +423,13 @@ namespace GHelper { AppConfig.Set("gpu_auto", (AppConfig.Get("gpu_auto") == 1) ? 0 : 1); VisualiseGPUMode(); - AutoGPUMode(); + gpuControl.AutoGPUMode(); } private void ButtonScreenAuto_Click(object? sender, EventArgs e) { AppConfig.Set("screen_auto", 1); - InitScreen(); - AutoScreen(); + screenControl.AutoScreen(); } @@ -595,70 +439,43 @@ namespace GHelper CheckBox chk = (CheckBox)sender; if (chk.Checked) - { Startup.Schedule(); - } else - { Startup.UnSchedule(); - } } private void CheckMatrix_CheckedChanged(object? sender, EventArgs e) { - if (sender is null) return; - CheckBox check = (CheckBox)sender; - AppConfig.Set("matrix_auto", check.Checked ? 1 : 0); - matrix?.SetMatrix(); + AppConfig.Set("matrix_auto", checkMatrix.Checked ? 1 : 0); + matrix.SetMatrix(); } private void ButtonMatrix_Click(object? sender, EventArgs e) { - string fileName = null; + matrix.OpenMatrixPicture(); + } - Thread t = new Thread(() => + public void SetMatrixRunning(int mode) + { + Invoke(delegate { - OpenFileDialog of = new OpenFileDialog(); - of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF"; - if (of.ShowDialog() == DialogResult.OK) - { - fileName = of.FileName; - } - return; + comboMatrixRunning.SelectedIndex = mode; }); - - t.SetApartmentState(ApartmentState.STA); - t.Start(); - t.Join(); - - if (fileName is not null) - { - AppConfig.Set("matrix_picture", fileName); - AppConfig.Set("matrix_running", 2); - - matrix?.SetMatrixPicture(fileName); - BeginInvoke(delegate - { - comboMatrixRunning.SelectedIndex = 2; - }); - } - - } private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e) { AppConfig.Set("matrix_running", comboMatrixRunning.SelectedIndex); - matrix?.SetMatrix(); + matrix.SetMatrix(); } private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e) { AppConfig.Set("matrix_brightness", comboMatrix.SelectedIndex); - matrix?.SetMatrix(); + matrix.SetMatrix(); } @@ -700,6 +517,14 @@ namespace GHelper } } + public void FansInit() + { + Invoke(delegate + { + if (fans != null && fans.Text != "") fans.InitAll(); + }); + } + public void FansToggle(int index = 0) { if (fans == null || fans.Text == "") @@ -757,7 +582,7 @@ namespace GHelper pictureColor2.BackColor = AsusUSB.Color2; pictureColor2.Visible = AsusUSB.HasSecondColor(); - if (AppConfig.ContainsModel("GA401")) + if (AsusUSB.HasColor()) { panelColor.Visible = false; } @@ -772,21 +597,16 @@ namespace GHelper public void InitMatrix() { - matrix = new AniMatrix(); - if (!matrix.IsValid) { panelMatrix.Visible = false; return; } - int brightness = AppConfig.Get("matrix_brightness"); - int running = AppConfig.Get("matrix_running"); + comboMatrix.SelectedIndex = Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1); + comboMatrixRunning.SelectedIndex = Math.Min(AppConfig.Get("matrix_running", 0), comboMatrixRunning.Items.Count - 1); - comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count - 1) : 0; - comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0; - - checkMatrix.Checked = (AppConfig.Get("matrix_auto") == 1); + checkMatrix.Checked = AppConfig.Is("matrix_auto"); checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged; } @@ -825,76 +645,26 @@ namespace GHelper private void Button120Hz_Click(object? sender, EventArgs e) { AppConfig.Set("screen_auto", 0); - SetScreen(1000, 1); + screenControl.SetScreen(1000, 1); } private void Button60Hz_Click(object? sender, EventArgs e) { AppConfig.Set("screen_auto", 0); - SetScreen(60, 0); + screenControl.SetScreen(60, 0); } - public void ToogleMiniled() - { - int miniled = (AppConfig.Get("miniled") == 1) ? 0 : 1; - AppConfig.Set("miniled", miniled); - SetScreen(-1, -1, miniled); - } private void ButtonMiniled_Click(object? sender, EventArgs e) { - ToogleMiniled(); + screenControl.ToogleMiniled(); } - public void SetScreen(int frequency = -1, int overdrive = -1, int miniled = -1) + + + public void VisualiseScreen(bool screenEnabled, bool screenAuto, int frequency, int maxFrequency, int overdrive, bool overdriveSetting, int miniled) { - if (NativeMethods.GetRefreshRate() < 0) // Laptop screen not detected or has unknown refresh rate - { - InitScreen(); - return; - } - - if (frequency >= 1000) - { - frequency = NativeMethods.GetRefreshRate(true); - } - - if (frequency > 0) - { - NativeMethods.SetRefreshRate(frequency); - } - - if (overdrive >= 0) - { - if (AppConfig.Get("no_overdrive") == 1) overdrive = 0; - Program.acpi.DeviceSet(AsusACPI.ScreenOverdrive, overdrive, "ScreenOverdrive"); - - } - - if (miniled >= 0) - { - Program.acpi.DeviceSet(AsusACPI.ScreenMiniled, miniled, "Miniled"); - Debug.WriteLine("Miniled " + miniled); - } - - InitScreen(); - } - - public void InitScreen() - { - - int frequency = NativeMethods.GetRefreshRate(); - int maxFrequency = NativeMethods.GetRefreshRate(true); - - bool screenAuto = (AppConfig.Get("screen_auto") == 1); - bool overdriveSetting = (AppConfig.Get("no_overdrive") != 1); - - int overdrive = Program.acpi.DeviceGet(AsusACPI.ScreenOverdrive); - int miniled = Program.acpi.DeviceGet(AsusACPI.ScreenMiniled); - - bool screenEnabled = (frequency >= 0); - ButtonEnabled(button60Hz, screenEnabled); ButtonEnabled(button120Hz, screenEnabled); ButtonEnabled(buttonScreenAuto, screenEnabled); @@ -934,15 +704,12 @@ namespace GHelper if (miniled >= 0) { buttonMiniled.Activated = (miniled == 1); - AppConfig.Set("miniled", miniled); } else { buttonMiniled.Visible = false; } - AppConfig.Set("frequency", frequency); - AppConfig.Set("overdrive", overdrive); } private void ButtonQuit_Click(object? sender, EventArgs e) @@ -960,9 +727,6 @@ namespace GHelper if (keyb != null && keyb.Text != "") keyb.Close(); } - public void CloseOthers() - { - } private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e) { @@ -975,17 +739,23 @@ namespace GHelper private void ButtonUltimate_Click(object? sender, EventArgs e) { - SetGPUMode(AsusACPI.GPUModeUltimate); + gpuControl.SetGPUMode(AsusACPI.GPUModeUltimate); } private void ButtonStandard_Click(object? sender, EventArgs e) { - SetGPUMode(AsusACPI.GPUModeStandard); + gpuControl.SetGPUMode(AsusACPI.GPUModeStandard); } private void ButtonEco_Click(object? sender, EventArgs e) { - SetGPUMode(AsusACPI.GPUModeEco); + gpuControl.SetGPUMode(AsusACPI.GPUModeEco); + } + + + private void ButtonStopGPU_Click(object? sender, EventArgs e) + { + gpuControl.KillGPUApps(); } public async void RefreshSensors(bool force = false) @@ -1030,389 +800,59 @@ namespace GHelper } - - private void SetPerformanceLabel() - { - labelPerf.Text = Properties.Strings.PerformanceMode + ": " + Modes.GetCurrentName() + (customFans ? "+" : "") + ((customPower > 0) ? " " + customPower + "W" : ""); - } - - public void SetPower() - { - - int limit_total = AppConfig.GetMode("limit_total"); - int limit_cpu = AppConfig.GetMode("limit_cpu"); - int limit_fast = AppConfig.GetMode("limit_fast"); - - if (limit_total > AsusACPI.MaxTotal) return; - if (limit_total < AsusACPI.MinTotal) return; - - if (limit_cpu > AsusACPI.MaxCPU) return; - if (limit_cpu < AsusACPI.MinCPU) return; - - if (limit_fast > AsusACPI.MaxTotal) return; - if (limit_fast < AsusACPI.MinTotal) return; - - // SPL + SPPT togeher in one slider - if (Program.acpi.DeviceGet(AsusACPI.PPT_TotalA0) >= 0) - { - Program.acpi.DeviceSet(AsusACPI.PPT_TotalA0, limit_total, "PowerLimit A0"); - Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, limit_total, "PowerLimit A3"); - customPower = limit_total; - } - - if (Program.acpi.IsAllAmdPPT()) // CPU limit all amd models - { - Program.acpi.DeviceSet(AsusACPI.PPT_CPUB0, limit_cpu, "PowerLimit B0"); - customPower = limit_cpu; - } - else if (Program.acpi.DeviceGet(AsusACPI.PPT_APUC1) >= 0) // FPPT boost for non all-amd models - { - Program.acpi.DeviceSet(AsusACPI.PPT_APUC1, limit_fast, "PowerLimit C1"); - customPower = limit_fast; - } - - - Program.settingsForm.BeginInvoke(SetPerformanceLabel); - - } - - - public void SetGPUClocks(bool launchAsAdmin = true) - { - - int gpu_core = AppConfig.GetMode("gpu_core"); - int gpu_memory = AppConfig.GetMode("gpu_memory"); - - if (gpu_core == -1 && gpu_memory == -1) return; - - //if ((gpu_core > -5 && gpu_core < 5) && (gpu_memory > -5 && gpu_memory < 5)) launchAsAdmin = false; - - if (Program.acpi.DeviceGet(AsusACPI.GPUEco) == 1) return; - if (HardwareControl.GpuControl is null) return; - if (!HardwareControl.GpuControl!.IsNvidia) return; - - using NvidiaGpuControl nvControl = (NvidiaGpuControl)HardwareControl.GpuControl; - try - { - int getStatus = nvControl.GetClocks(out int current_core, out int current_memory); - if (getStatus != -1) - { - if (Math.Abs(gpu_core - current_core) < 5 && Math.Abs(gpu_memory - current_memory) < 5) return; - } - - int setStatus = nvControl.SetClocks(gpu_core, gpu_memory); - if (launchAsAdmin && setStatus == -1) ProcessHelper.RunAsAdmin("gpu"); - - } - catch (Exception ex) - { - Logger.WriteLine(ex.ToString()); - } - } - - public void SetGPUPower() - { - - int gpu_boost = AppConfig.GetMode("gpu_boost"); - int gpu_temp = AppConfig.GetMode("gpu_temp"); - - - if (gpu_boost < AsusACPI.MinGPUBoost || gpu_boost > AsusACPI.MaxGPUBoost) return; - if (gpu_temp < AsusACPI.MinGPUTemp || gpu_temp > AsusACPI.MaxGPUTemp) return; - - if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC0) >= 0) - { - Program.acpi.DeviceSet(AsusACPI.PPT_GPUC0, gpu_boost, "PowerLimit C0"); - } - - if (Program.acpi.DeviceGet(AsusACPI.PPT_GPUC2) >= 0) - { - Program.acpi.DeviceSet(AsusACPI.PPT_GPUC2, gpu_temp, "PowerLimit C2"); - } - - } - - - public void AutoUV() - { - if (!AppConfig.IsMode("auto_uv")) return; - SetUV(); - } - - public void SetUV(bool launchAsAdmin = false) - { - - if (!ProcessHelper.IsUserAdministrator()) - { - if (launchAsAdmin) ProcessHelper.RunAsAdmin("uv"); - return; - } - - if (!Undervolter.IsAMD()) return; - - int cpuUV = AppConfig.GetMode("cpu_uv", 0); - int igpuUV = AppConfig.GetMode("igpu_uv", 0); - int cpuTemp = AppConfig.GetMode("cpu_temp"); - - try - { - if (cpuUV >= Undervolter.MinCPUUV && cpuUV <= Undervolter.MaxCPUUV) - { - SendCommand.set_coall(cpuUV); - } - - if (igpuUV >= Undervolter.MinIGPUUV && igpuUV <= Undervolter.MaxIGPUUV) - { - SendCommand.set_cogfx(igpuUV); - } - - if (cpuTemp >= Undervolter.MinTemp && cpuTemp <= Undervolter.MaxTemp) - { - SendCommand.set_tctl_temp((uint)cpuTemp); - SendCommand.set_apu_skin_temp_limit((uint)cpuTemp); - } - - } - catch (Exception ex) - { - Logger.WriteLine("UV Error: " + ex.ToString()); - } - } - - - protected void LabelFansResult(string text) + public void LabelFansResult(string text) { if (fans != null && fans.Text != "") fans.LabelFansResult(text); } - - public void AutoFans(bool force = false) + public void ShowMode(int mode) { - customFans = false; - - if (AppConfig.IsMode("auto_apply") || force) + Invoke(delegate { + buttonSilent.Activated = false; + buttonBalanced.Activated = false; + buttonTurbo.Activated = false; + buttonFans.Activated = false; - bool xgmFan = false; - if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) + menuSilent.Checked = false; + menuBalanced.Checked = false; + menuTurbo.Checked = false; + + switch (mode) { - AsusUSB.SetXGMFan(AppConfig.GetFanConfig(AsusFan.XGM)); - xgmFan = true; - } - - int cpuResult = Program.acpi.SetFanCurve(AsusFan.CPU, AppConfig.GetFanConfig(AsusFan.CPU)); - int gpuResult = Program.acpi.SetFanCurve(AsusFan.GPU, AppConfig.GetFanConfig(AsusFan.GPU)); - - - if (AppConfig.Is("mid_fan")) - Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.GetFanConfig(AsusFan.Mid)); - - - // something went wrong, resetting to default profile - if (cpuResult != 1 || gpuResult != 1) - { - int mode = Modes.GetCurrentBase(); - Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode); - Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "Reset Mode"); - LabelFansResult("ASUS BIOS rejected fan curve"); - } - else - { - LabelFansResult(""); - customFans = true; - } - - // force set PPTs for missbehaving bios on FX507/517 series - if ((AppConfig.ContainsModel("FX507") || AppConfig.ContainsModel("FX517") || xgmFan) && !AppConfig.IsMode("auto_apply_power")) - { - Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(1)); - Program.acpi.DeviceSet(AsusACPI.PPT_TotalA0, 80, "PowerLimit Fix A0"); - Program.acpi.DeviceSet(AsusACPI.PPT_APUA3, 80, "PowerLimit Fix A3"); - }); - } - - } - - Program.settingsForm.BeginInvoke(SetPerformanceLabel); - - } - - private static bool isManualModeRequired() - { - if (!AppConfig.IsMode("auto_apply_power")) - return false; - - return - AppConfig.Is("manual_mode") || - AppConfig.ContainsModel("GU604") || - AppConfig.ContainsModel("FX517") || - AppConfig.ContainsModel("G733"); - } - - public void AutoPower(int delay = 0) - { - - customPower = 0; - - bool applyPower = AppConfig.IsMode("auto_apply_power"); - bool applyFans = AppConfig.IsMode("auto_apply"); - //bool applyGPU = true; - - if (applyPower) - { - // force fan curve for misbehaving bios PPTs on G513 - if (AppConfig.ContainsModel("G513") && !applyFans) - { - delay = 500; - AutoFans(true); - } - - // Fix for models that don't support PPT settings in all modes, setting a "manual" mode for them - if (isManualModeRequired() && !applyFans) - { - AutoFans(true); - } - } - - if (delay > 0) - { - var timer = new System.Timers.Timer(delay); - timer.Elapsed += delegate - { - timer.Stop(); - timer.Dispose(); - - if (applyPower) SetPower(); - SetGPUPower(); - AutoUV(); - }; - timer.Start(); - } - else - { - if (applyPower) SetPower(); - SetGPUPower(); - AutoUV(); - } - - } - - - public void SetPerformanceMode(int mode = -1, bool notify = false) - { - - int oldMode = Modes.GetCurrent(); - if (mode < 0) mode = oldMode; - - buttonSilent.Activated = false; - buttonBalanced.Activated = false; - buttonTurbo.Activated = false; - buttonFans.Activated = false; - - menuSilent.Checked = false; - menuBalanced.Checked = false; - menuTurbo.Checked = false; - - switch (mode) - { - case AsusACPI.PerformanceSilent: - buttonSilent.Activated = true; - menuSilent.Checked = true; - break; - case AsusACPI.PerformanceTurbo: - buttonTurbo.Activated = true; - menuTurbo.Checked = true; - break; - case AsusACPI.PerformanceBalanced: - buttonBalanced.Activated = true; - menuBalanced.Checked = true; - break; - default: - if (Modes.Exists(mode)) - { - buttonFans.Activated = true; - switch (Modes.GetBase(mode)) - { - case AsusACPI.PerformanceSilent: - buttonFans.BorderColor = colorEco; - break; - case AsusACPI.PerformanceTurbo: - buttonFans.BorderColor = colorTurbo; - break; - default: - buttonFans.BorderColor = colorStandard; - break; - } - } - else - { + case AsusACPI.PerformanceSilent: + buttonSilent.Activated = true; + menuSilent.Checked = true; + break; + case AsusACPI.PerformanceTurbo: + buttonTurbo.Activated = true; + menuTurbo.Checked = true; + break; + case AsusACPI.PerformanceBalanced: buttonBalanced.Activated = true; menuBalanced.Checked = true; - mode = AsusACPI.PerformanceBalanced; - } - break; - } - - - Modes.SetCurrent(mode); - - SetPerformanceLabel(); - - if (isManualModeRequired()) - Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AsusACPI.PerformanceManual, "Manual Mode"); - else - Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Modes.GetBase(mode), "Mode"); - - if (AppConfig.Is("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM(); - - if (notify) - { - try - { - toast.RunToast(Modes.GetCurrentName(), SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery); + break; + default: + buttonFans.Activated = true; + buttonFans.BorderColor = Modes.GetBase(mode) switch + { + AsusACPI.PerformanceSilent => colorEco, + AsusACPI.PerformanceTurbo => colorTurbo, + _ => colorStandard, + }; + break; } - catch - { - Debug.WriteLine("Toast error"); - } - } - - SetGPUClocks(); - - AutoFans(); - AutoPower(1000); - - if (AppConfig.Get("auto_apply_power_plan") != 0) - { - if (AppConfig.GetModeString("scheme") is not null) - NativeMethods.SetPowerScheme(AppConfig.GetModeString("scheme")); - else - NativeMethods.SetPowerScheme(Modes.GetBase(mode)); - } - - if (AppConfig.GetMode("auto_boost") != -1) - { - NativeMethods.SetCPUBoost(AppConfig.GetMode("auto_boost")); - } - - if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0) - { - Debug.WriteLine("Effective :" + activeScheme); - } - - if (fans != null && fans.Text != "") - { - fans.InitAll(); - } + }); } - public void CyclePerformanceMode() + public void SetModeLabel(string modeText) { - SetPerformanceMode(Modes.GetNext(Control.ModifierKeys == Keys.Shift), true); + Invoke(delegate + { + labelPerf.Text = modeText; + }); } @@ -1427,132 +867,16 @@ namespace GHelper } - public void AutoPerformance(bool powerChanged = false) - { - var Plugged = SystemInformation.PowerStatus.PowerLineStatus; - int mode = AppConfig.Get("performance_" + (int)Plugged); - if (mode != -1) - SetPerformanceMode(mode, powerChanged); - else - SetPerformanceMode(Modes.GetCurrent()); - } - - - public void AutoScreen(bool force = false) - { - if (force || AppConfig.Is("screen_auto")) - { - if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online) - SetScreen(1000, 1); - else - SetScreen(60, 0); - } - else - { - SetScreen(overdrive: AppConfig.Get("overdrive")); - } - - - - } - - public static bool IsPlugged() - { - bool optimizedUSBC = AppConfig.Get("optimized_usbc") != 1; - - return SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online && - (optimizedUSBC || Program.acpi.DeviceGet(AsusACPI.ChargerMode) < AsusACPI.ChargerUSB); - - } - - public bool AutoGPUMode() + public void VisualizeXGM(bool connected, bool activated) { - bool GpuAuto = AppConfig.Is("gpu_auto"); - bool ForceGPU = AppConfig.ContainsModel("503"); - - int GpuMode = AppConfig.Get("gpu_mode"); - - if (!GpuAuto && !ForceGPU) return false; - - int eco = Program.acpi.DeviceGet(AsusACPI.GPUEco); - int mux = Program.acpi.DeviceGet(AsusACPI.GPUMux); - - if (mux == 0) // GPU in Ultimate, ignore - return false; - else - { - - if (ReEnableGPU()) return true; - - if (eco == 1) - if ((GpuAuto && IsPlugged()) || (ForceGPU && GpuMode == AsusACPI.GPUModeStandard)) - { - SetGPUEco(0); - return true; - } - if (eco == 0) - if ((GpuAuto && !IsPlugged()) || (ForceGPU && GpuMode == AsusACPI.GPUModeEco)) - { - - if (HardwareControl.IsUsedGPU()) - { - DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertDGPU, Properties.Strings.AlertDGPUTitle, MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.No) return false; - } - - SetGPUEco(1); - return true; - } - } - - return false; - - } - - public bool ReEnableGPU() - { - - if (AppConfig.Get("gpu_reenable") != 1) return false; - if (Screen.AllScreens.Length <= 1) return false; - - Logger.WriteLine("Re-enabling gpu for 503 model"); - - Thread.Sleep(1000); - SetGPUEco(1); - Thread.Sleep(1000); - SetGPUEco(0); - return true; - } - - private void UltimateUI(bool ultimate) - { - if (!ultimate) - { - tableGPU.Controls.Remove(buttonUltimate); - tablePerf.ColumnCount = 0; - tableGPU.ColumnCount = 0; - tableScreen.ColumnCount = 0; - menuUltimate.Visible = false; - - } - //tableLayoutMatrix.ColumnCount = 0; - } - - public void InitXGM() - { - bool connected = Program.acpi.IsXGConnected(); buttonXGM.Enabled = buttonXGM.Visible = connected; - if (!connected) return; - int activated = Program.acpi.DeviceGet(AsusACPI.GPUXG); - if (activated < 0) return; + buttonXGM.Activated = activated; - buttonXGM.Activated = (activated == 1); - - if (buttonXGM.Activated) + if (activated) { ButtonEnabled(buttonOptimized, false); ButtonEnabled(buttonEco, false); @@ -1569,202 +893,54 @@ namespace GHelper } - - public int InitGPUMode() + public void HideUltimateMode() { + tableGPU.Controls.Remove(buttonUltimate); + tablePerf.ColumnCount = 0; + tableGPU.ColumnCount = 0; + tableScreen.ColumnCount = 0; + menuUltimate.Visible = false; + } - int eco = Program.acpi.DeviceGet(AsusACPI.GPUEco); - int mux = Program.acpi.DeviceGet(AsusACPI.GPUMux); + public void HideGPUModes() + { + isGpuSection = false; - Logger.WriteLine("Eco flag : " + eco); - Logger.WriteLine("Mux flag : " + mux); + buttonEco.Visible = false; + buttonStandard.Visible = false; + buttonUltimate.Visible = false; + buttonOptimized.Visible = false; - int GpuMode; + buttonStopGPU.Visible = true; - if (mux == 0) - GpuMode = AsusACPI.GPUModeUltimate; - else - { - if (eco == 1) - GpuMode = AsusACPI.GPUModeEco; - else - GpuMode = AsusACPI.GPUModeStandard; - - UltimateUI(mux == 1); - - if (eco < 0 && mux < 0) - { - isGpuSection = tableGPU.Visible = false; - SetContextMenu(); - if (HardwareControl.FormatFan(Program.acpi.DeviceGet(AsusACPI.GPU_Fan)) is null) panelGPU.Visible = false; - } - - } - - AppConfig.Set("gpu_mode", GpuMode); - - ButtonEnabled(buttonOptimized, true); - ButtonEnabled(buttonEco, true); - ButtonEnabled(buttonStandard, true); - ButtonEnabled(buttonUltimate, true); - - InitXGM(); - - VisualiseGPUMode(GpuMode); - - return GpuMode; + SetContextMenu(); + if (HardwareControl.FormatFan(Program.acpi.DeviceGet(AsusACPI.GPU_Fan)) is null) panelGPU.Visible = false; } - public void RestartGPU(bool confirm = true) + public void LockGPUModes(string text = null) { - if (HardwareControl.GpuControl is null) return; - if (!HardwareControl.GpuControl!.IsNvidia) return; - - if (confirm) + Invoke(delegate { - DialogResult dialogResult = MessageBox.Show(Properties.Strings.RestartGPU, Properties.Strings.EcoMode, MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.No) return; - } + if (text is null) text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ..."; - ProcessHelper.RunAsAdmin("gpurestart"); + ButtonEnabled(buttonOptimized, false); + ButtonEnabled(buttonEco, false); + ButtonEnabled(buttonStandard, false); + ButtonEnabled(buttonUltimate, false); + ButtonEnabled(buttonXGM, false); - if (!ProcessHelper.IsUserAdministrator()) return; - - Logger.WriteLine("Trying to restart dGPU"); - - Task.Run(async () => - { - Program.settingsForm.BeginInvoke(delegate - { - labelTipGPU.Text = "Restarting GPU ..."; - ButtonEnabled(buttonOptimized, false); - ButtonEnabled(buttonEco, false); - ButtonEnabled(buttonStandard, false); - ButtonEnabled(buttonUltimate, false); - }); - - var nvControl = (NvidiaGpuControl)HardwareControl.GpuControl; - bool status = nvControl.RestartGPU(); - - Program.settingsForm.BeginInvoke(delegate - { - labelTipGPU.Text = status ? "GPU Restarted, you can try Eco mode again" : "Failed to restart GPU"; - InitGPUMode(); - }); + labelGPU.Text = text; }); - - } - - - public void SetGPUEco(int eco, bool hardWay = false) - { - - ButtonEnabled(buttonOptimized, false); - ButtonEnabled(buttonEco, false); - ButtonEnabled(buttonStandard, false); - ButtonEnabled(buttonUltimate, false); - ButtonEnabled(buttonXGM, false); - - labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUChanging + " ..."; - - Task.Run(async () => - { - - int status = 1; - - if (eco == 1) HardwareControl.KillGPUApps(); - - Logger.WriteLine($"Running eco command {eco}"); - - status = Program.acpi.SetGPUEco(eco); - - if (status == 0 && eco == 1 && hardWay) RestartGPU(); - - await Task.Delay(TimeSpan.FromMilliseconds(100)); - Program.settingsForm.BeginInvoke(delegate - { - InitGPUMode(); - AutoScreen(); - }); - - if (eco == 0) - { - await Task.Delay(TimeSpan.FromMilliseconds(3000)); - HardwareControl.RecreateGpuControl(); - SetGPUClocks(false); - } - - }); - - - } - - public void SetGPUMode(int GPUMode) - { - - int CurrentGPU = AppConfig.Get("gpu_mode"); - AppConfig.Set("gpu_auto", 0); - - if (CurrentGPU == GPUMode) - { - VisualiseGPUMode(); - return; - } - - var restart = false; - var changed = false; - - if (CurrentGPU == AsusACPI.GPUModeUltimate) - { - DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertUltimateOff, Properties.Strings.AlertUltimateTitle, MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - { - Program.acpi.DeviceSet(AsusACPI.GPUMux, 1, "GPUMux"); - restart = true; - changed = true; - } - } - else if (GPUMode == AsusACPI.GPUModeUltimate) - { - DialogResult dialogResult = MessageBox.Show(Properties.Strings.AlertUltimateOn, Properties.Strings.AlertUltimateTitle, MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - { - Program.acpi.DeviceSet(AsusACPI.GPUMux, 0, "GPUMux"); - restart = true; - changed = true; - } - - } - else if (GPUMode == AsusACPI.GPUModeEco) - { - VisualiseGPUMode(GPUMode); - SetGPUEco(1, true); - changed = true; - } - else if (GPUMode == AsusACPI.GPUModeStandard) - { - VisualiseGPUMode(GPUMode); - SetGPUEco(0); - changed = true; - } - - if (changed) - { - AppConfig.Set("gpu_mode", GPUMode); - } - - if (restart) - { - VisualiseGPUMode(); - Process.Start("shutdown", "/r /t 1"); - } - } public void VisualiseGPUMode(int GPUMode = -1) { + ButtonEnabled(buttonOptimized, true); + ButtonEnabled(buttonEco, true); + ButtonEnabled(buttonStandard, true); + ButtonEnabled(buttonUltimate, true); if (GPUMode == -1) GPUMode = AppConfig.Get("gpu_mode"); @@ -1814,23 +990,19 @@ namespace GHelper private void ButtonSilent_Click(object? sender, EventArgs e) { - SetPerformanceMode(AsusACPI.PerformanceSilent); + Program.modeControl.SetPerformanceMode(AsusACPI.PerformanceSilent); } private void ButtonBalanced_Click(object? sender, EventArgs e) { - SetPerformanceMode(AsusACPI.PerformanceBalanced); + Program.modeControl.SetPerformanceMode(AsusACPI.PerformanceBalanced); } private void ButtonTurbo_Click(object? sender, EventArgs e) { - SetPerformanceMode(AsusACPI.PerformanceTurbo); + Program.modeControl.SetPerformanceMode(AsusACPI.PerformanceTurbo); } - private void Settings_Load(object sender, EventArgs e) - { - - } public void ButtonEnabled(RButton but, bool enabled) { @@ -1838,12 +1010,6 @@ namespace GHelper but.BackColor = but.Enabled ? Color.FromArgb(255, but.BackColor) : Color.FromArgb(100, but.BackColor); } - public void SetStartupCheck(bool status) - { - checkStartup.CheckedChanged -= CheckStartup_CheckedChanged; - checkStartup.Checked = status; - checkStartup.CheckedChanged += CheckStartup_CheckedChanged; - } public void SetBatteryChargeLimit(int limit) { diff --git a/app/ControlHelper.cs b/app/UI/ControlHelper.cs similarity index 99% rename from app/ControlHelper.cs rename to app/UI/ControlHelper.cs index 637fa56f..8addc332 100644 --- a/app/ControlHelper.cs +++ b/app/UI/ControlHelper.cs @@ -1,7 +1,6 @@ -using CustomControls; +using GHelper.UI; using System.Drawing.Drawing2D; using System.Windows.Forms.DataVisualization.Charting; -using WinFormsSliderBar; public static class ControlHelper { diff --git a/app/CustomContextMenu.cs b/app/UI/CustomContextMenu.cs similarity index 92% rename from app/CustomContextMenu.cs rename to app/UI/CustomContextMenu.cs index c45dd4d7..194fffd9 100644 --- a/app/CustomContextMenu.cs +++ b/app/UI/CustomContextMenu.cs @@ -1,11 +1,11 @@ using System.Runtime.InteropServices; -namespace GHelper +namespace GHelper.UI { class CustomContextMenu : ContextMenuStrip { [DllImport("dwmapi.dll", CharSet = CharSet.Unicode, SetLastError = true)] - private static extern long DwmSetWindowAttribute(IntPtr hwnd, + private static extern long DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref DWM_WINDOW_CORNER_PREFERENCE pvAttribute, uint cbAttribute); diff --git a/app/CustomControls.cs b/app/UI/CustomControls.cs similarity index 91% rename from app/CustomControls.cs rename to app/UI/CustomControls.cs index 6c237dee..cd1da12c 100644 --- a/app/CustomControls.cs +++ b/app/UI/CustomControls.cs @@ -3,7 +3,7 @@ using System.ComponentModel; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; -namespace CustomControls +namespace GHelper.UI { public class RForm : Form @@ -28,7 +28,7 @@ namespace CustomControls public static extern bool CheckSystemDarkModeStatus(); [DllImport("DwmApi")] //System.Runtime.InteropServices - private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize); + private static extern int DwmSetWindowAttribute(nint hwnd, int attr, int[] attrValue, int attrSize); public bool darkTheme = false; @@ -72,7 +72,7 @@ namespace CustomControls public bool InitTheme(bool setDPI = false) { bool newDarkTheme = CheckSystemDarkModeStatus(); - bool changed = (darkTheme != newDarkTheme); + bool changed = darkTheme != newDarkTheme; darkTheme = newDarkTheme; InitColors(darkTheme); @@ -82,7 +82,7 @@ namespace CustomControls if (changed) { - DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4); + DwmSetWindowAttribute(Handle, 20, new[] { darkTheme ? 1 : 0 }, 4); ControlHelper.Adjust(this, changed); } @@ -182,8 +182,8 @@ namespace CustomControls }; var ps = new PAINTSTRUCT(); bool shoulEndPaint = false; - IntPtr dc; - if (m.WParam == IntPtr.Zero) + nint dc; + if (m.WParam == nint.Zero) { dc = BeginPaint(Handle, ref ps); m.WParam = dc; @@ -196,7 +196,7 @@ namespace CustomControls var rgn = CreateRectRgn(innerInnerBorder.Left, innerInnerBorder.Top, innerInnerBorder.Right, innerInnerBorder.Bottom); - + SelectClipRgn(dc, rgn); DefWndProc(ref m); DeleteObject(rgn); @@ -240,7 +240,7 @@ namespace CustomControls [StructLayout(LayoutKind.Sequential)] public struct PAINTSTRUCT { - public IntPtr hdc; + public nint hdc; public bool fErase; public int rcPaint_left; public int rcPaint_top; @@ -258,17 +258,17 @@ namespace CustomControls public int reserved8; } [DllImport("user32.dll")] - private static extern IntPtr BeginPaint(IntPtr hWnd, + private static extern nint BeginPaint(nint hWnd, [In, Out] ref PAINTSTRUCT lpPaint); [DllImport("user32.dll")] - private static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint); + private static extern bool EndPaint(nint hWnd, ref PAINTSTRUCT lpPaint); [DllImport("gdi32.dll")] - public static extern int SelectClipRgn(IntPtr hDC, IntPtr hRgn); + public static extern int SelectClipRgn(nint hDC, nint hRgn); [DllImport("user32.dll")] - public static extern int GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase); + public static extern int GetUpdateRgn(nint hwnd, nint hrgn, bool fErase); public enum RegionFlags { ERROR = 0, @@ -277,10 +277,10 @@ namespace CustomControls COMPLEXREGION = 3, } [DllImport("gdi32.dll")] - internal static extern bool DeleteObject(IntPtr hObject); + internal static extern bool DeleteObject(nint hObject); [DllImport("gdi32.dll")] - private static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2); + private static extern nint CreateRectRgn(int x1, int y1, int x2, int y2); } public class RButton : Button @@ -316,7 +316,7 @@ namespace CustomControls set { if (activated != value) - this.Invalidate(); + Invalidate(); activated = value; } @@ -362,19 +362,19 @@ namespace CustomControls float ratio = pevent.Graphics.DpiX / 192.0f; int border = (int)(ratio * borderSize); - Rectangle rectSurface = this.ClientRectangle; + Rectangle rectSurface = ClientRectangle; Rectangle rectBorder = Rectangle.Inflate(rectSurface, -border, -border); Color borderDrawColor = activated ? borderColor : Color.Transparent; using (GraphicsPath pathSurface = GetFigurePath(rectSurface, borderRadius + border)) using (GraphicsPath pathBorder = GetFigurePath(rectBorder, borderRadius)) - using (Pen penSurface = new Pen(this.Parent.BackColor, border)) + using (Pen penSurface = new Pen(Parent.BackColor, border)) using (Pen penBorder = new Pen(borderDrawColor, border)) { penBorder.Alignment = PenAlignment.Outset; pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias; - this.Region = new Region(pathSurface); + Region = new Region(pathSurface); pevent.Graphics.DrawPath(penSurface, pathSurface); pevent.Graphics.DrawPath(penBorder, pathBorder); } @@ -388,7 +388,7 @@ namespace CustomControls rect.Height -= Image.Height; } TextFormatFlags flags = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak; - TextRenderer.DrawText(pevent.Graphics, this.Text, this.Font, rect, Color.Gray, flags); + TextRenderer.DrawText(pevent.Graphics, Text, Font, rect, Color.Gray, flags); } diff --git a/app/CustomControls.resx b/app/UI/CustomControls.resx similarity index 100% rename from app/CustomControls.resx rename to app/UI/CustomControls.resx diff --git a/app/Slider.cs b/app/UI/Slider.cs similarity index 99% rename from app/Slider.cs rename to app/UI/Slider.cs index 203a615f..b179fd3c 100644 --- a/app/Slider.cs +++ b/app/UI/Slider.cs @@ -1,6 +1,6 @@ using System.Drawing.Drawing2D; -namespace WinFormsSliderBar +namespace GHelper.UI { public static class GraphicsExtensions { diff --git a/app/Updates.Designer.cs b/app/Updates.Designer.cs index 11f44b39..444f997a 100644 --- a/app/Updates.Designer.cs +++ b/app/Updates.Designer.cs @@ -1,4 +1,6 @@ -namespace GHelper +using GHelper.UI; + +namespace GHelper { partial class Updates { @@ -33,6 +35,8 @@ labelBIOS = new Label(); pictureBios = new PictureBox(); panelBiosTitle = new Panel(); + labelUpdates = new Label(); + buttonRefresh = new RButton(); panelBios = new Panel(); panelDrivers = new Panel(); tableDrivers = new TableLayoutPanel(); @@ -56,21 +60,21 @@ tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBios.Dock = DockStyle.Top; - tableBios.Location = new Point(10, 10); - tableBios.Margin = new Padding(2); - tableBios.MinimumSize = new Size(550, 0); + tableBios.Location = new Point(20, 20); + tableBios.Margin = new Padding(4); + tableBios.MinimumSize = new Size(1100, 0); tableBios.Name = "tableBios"; - tableBios.Size = new Size(608, 0); + tableBios.Size = new Size(1216, 0); tableBios.TabIndex = 0; // // labelBIOS // labelBIOS.AutoSize = true; labelBIOS.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelBIOS.Location = new Point(34, 14); - labelBIOS.Margin = new Padding(2, 0, 2, 0); + labelBIOS.Location = new Point(68, 23); + labelBIOS.Margin = new Padding(4, 0, 4, 0); labelBIOS.Name = "labelBIOS"; - labelBIOS.Size = new Size(35, 15); + labelBIOS.Size = new Size(68, 32); labelBIOS.TabIndex = 1; labelBIOS.Text = "BIOS"; // @@ -78,34 +82,63 @@ // pictureBios.BackgroundImage = (Image)resources.GetObject("pictureBios.BackgroundImage"); pictureBios.BackgroundImageLayout = ImageLayout.Zoom; - pictureBios.Location = new Point(14, 14); - pictureBios.Margin = new Padding(2); + pictureBios.Location = new Point(28, 23); + pictureBios.Margin = new Padding(4); pictureBios.Name = "pictureBios"; - pictureBios.Size = new Size(16, 16); + pictureBios.Size = new Size(32, 32); pictureBios.TabIndex = 2; pictureBios.TabStop = false; // // panelBiosTitle // + panelBiosTitle.Controls.Add(labelUpdates); + panelBiosTitle.Controls.Add(buttonRefresh); panelBiosTitle.Controls.Add(labelBIOS); panelBiosTitle.Controls.Add(pictureBios); panelBiosTitle.Dock = DockStyle.Top; panelBiosTitle.Location = new Point(0, 0); - panelBiosTitle.Margin = new Padding(2); + panelBiosTitle.Margin = new Padding(4); panelBiosTitle.Name = "panelBiosTitle"; - panelBiosTitle.Size = new Size(628, 31); + panelBiosTitle.Size = new Size(1256, 62); panelBiosTitle.TabIndex = 3; // + // labelUpdates + // + labelUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Right; + labelUpdates.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelUpdates.Location = new Point(941, 23); + labelUpdates.Name = "labelUpdates"; + labelUpdates.Size = new Size(245, 32); + labelUpdates.TabIndex = 4; + labelUpdates.Text = "Updates Available"; + // + // buttonRefresh + // + buttonRefresh.Activated = false; + buttonRefresh.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRefresh.BackColor = SystemColors.ControlLight; + buttonRefresh.BorderColor = Color.Transparent; + buttonRefresh.BorderRadius = 5; + buttonRefresh.FlatAppearance.BorderSize = 0; + buttonRefresh.FlatStyle = FlatStyle.Flat; + buttonRefresh.Image = Properties.Resources.icons8_refresh_32; + buttonRefresh.Location = new Point(1183, 14); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Secondary = true; + buttonRefresh.Size = new Size(52, 46); + buttonRefresh.TabIndex = 3; + buttonRefresh.UseVisualStyleBackColor = false; + // // panelBios // panelBios.AutoSize = true; panelBios.Controls.Add(tableBios); panelBios.Dock = DockStyle.Top; - panelBios.Location = new Point(0, 31); - panelBios.Margin = new Padding(2); + panelBios.Location = new Point(0, 62); + panelBios.Margin = new Padding(4); panelBios.Name = "panelBios"; - panelBios.Padding = new Padding(10); - panelBios.Size = new Size(628, 20); + panelBios.Padding = new Padding(20); + panelBios.Size = new Size(1256, 40); panelBios.TabIndex = 4; // // panelDrivers @@ -113,11 +146,11 @@ panelDrivers.AutoSize = true; panelDrivers.Controls.Add(tableDrivers); panelDrivers.Dock = DockStyle.Top; - panelDrivers.Location = new Point(0, 73); - panelDrivers.Margin = new Padding(2); + panelDrivers.Location = new Point(0, 146); + panelDrivers.Margin = new Padding(4); panelDrivers.Name = "panelDrivers"; - panelDrivers.Padding = new Padding(10); - panelDrivers.Size = new Size(628, 20); + panelDrivers.Padding = new Padding(20); + panelDrivers.Size = new Size(1256, 40); panelDrivers.TabIndex = 6; // // tableDrivers @@ -129,11 +162,11 @@ tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableDrivers.Dock = DockStyle.Top; - tableDrivers.Location = new Point(10, 10); - tableDrivers.Margin = new Padding(2); - tableDrivers.MinimumSize = new Size(550, 0); + tableDrivers.Location = new Point(20, 20); + tableDrivers.Margin = new Padding(4); + tableDrivers.MinimumSize = new Size(1100, 0); tableDrivers.Name = "tableDrivers"; - tableDrivers.Size = new Size(608, 0); + tableDrivers.Size = new Size(1216, 0); tableDrivers.TabIndex = 0; // // panelDriversTitle @@ -141,20 +174,20 @@ panelDriversTitle.Controls.Add(labelDrivers); panelDriversTitle.Controls.Add(pictureDrivers); panelDriversTitle.Dock = DockStyle.Top; - panelDriversTitle.Location = new Point(0, 51); - panelDriversTitle.Margin = new Padding(2); + panelDriversTitle.Location = new Point(0, 102); + panelDriversTitle.Margin = new Padding(4); panelDriversTitle.Name = "panelDriversTitle"; - panelDriversTitle.Size = new Size(628, 22); + panelDriversTitle.Size = new Size(1256, 44); panelDriversTitle.TabIndex = 5; // // labelDrivers // labelDrivers.AutoSize = true; labelDrivers.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); - labelDrivers.Location = new Point(34, 4); - labelDrivers.Margin = new Padding(2, 0, 2, 0); + labelDrivers.Location = new Point(68, 6); + labelDrivers.Margin = new Padding(4, 0, 4, 0); labelDrivers.Name = "labelDrivers"; - labelDrivers.Size = new Size(126, 15); + labelDrivers.Size = new Size(254, 32); labelDrivers.TabIndex = 1; labelDrivers.Text = "Drivers and Software"; // @@ -162,24 +195,24 @@ // pictureDrivers.BackgroundImage = (Image)resources.GetObject("pictureDrivers.BackgroundImage"); pictureDrivers.BackgroundImageLayout = ImageLayout.Zoom; - pictureDrivers.Location = new Point(14, 4); - pictureDrivers.Margin = new Padding(2); + pictureDrivers.Location = new Point(28, 6); + pictureDrivers.Margin = new Padding(4); pictureDrivers.Name = "pictureDrivers"; - pictureDrivers.Size = new Size(16, 16); + pictureDrivers.Size = new Size(32, 32); pictureDrivers.TabIndex = 2; pictureDrivers.TabStop = false; // // Updates // - AutoScaleDimensions = new SizeF(96F, 96F); + AutoScaleDimensions = new SizeF(192F, 192F); AutoScaleMode = AutoScaleMode.Dpi; AutoScroll = true; - ClientSize = new Size(628, 345); + ClientSize = new Size(1256, 690); Controls.Add(panelDrivers); Controls.Add(panelDriversTitle); Controls.Add(panelBios); Controls.Add(panelBiosTitle); - Margin = new Padding(2); + Margin = new Padding(4); MinimizeBox = false; Name = "Updates"; ShowIcon = false; @@ -211,5 +244,7 @@ private Panel panelDriversTitle; private Label labelDrivers; private PictureBox pictureDrivers; + private RButton buttonRefresh; + private Label labelUpdates; } } \ No newline at end of file diff --git a/app/Updates.cs b/app/Updates.cs index 5bec0c9f..0c4499a7 100644 --- a/app/Updates.cs +++ b/app/Updates.cs @@ -1,5 +1,4 @@ -using CustomControls; -using HidSharp; +using GHelper.UI; using System.Diagnostics; using System.Management; using System.Net; @@ -23,21 +22,34 @@ namespace GHelper static string model; static string bios; - public Updates() + static int updatesCount = 0; + private static long lastUpdate; + + private void LoadUpdates() { - InitializeComponent(); - InitTheme(); + + if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastUpdate) < 5000) return; + lastUpdate = DateTimeOffset.Now.ToUnixTimeMilliseconds(); InitBiosAndModel(); + updatesCount = 0; + labelUpdates.ForeColor = colorEco; + labelUpdates.Text = Properties.Strings.NoNewUpdates; + + Text = Properties.Strings.BiosAndDriverUpdates + ": " + model + " " + bios; labelBIOS.Text = "BIOS"; labelDrivers.Text = Properties.Strings.DriverAndSoftware; SuspendLayout(); + tableBios.Visible = false; tableDrivers.Visible = false; + ClearTable(tableBios); + ClearTable(tableDrivers); + Task.Run(async () => { DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDBIOS?website=global&model={model}&cpu=", 1, tableBios); @@ -47,10 +59,36 @@ namespace GHelper { DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDDrivers?website=global&model={model}&cpu={model}&osid=52", 0, tableDrivers); }); + } + private void ClearTable(TableLayoutPanel tableLayoutPanel) + { + while (tableLayoutPanel.Controls.Count > 0) + { + tableLayoutPanel.Controls[0].Dispose(); + } + + tableLayoutPanel.RowCount = 0; + } + + public Updates() + { + InitializeComponent(); + InitTheme(true); + + + LoadUpdates(); + + //buttonRefresh.Visible = false; + buttonRefresh.Click += ButtonRefresh_Click; Shown += Updates_Shown; } + private void ButtonRefresh_Click(object? sender, EventArgs e) + { + LoadUpdates(); + } + private void Updates_Shown(object? sender, EventArgs e) { Height = Program.settingsForm.Height; @@ -90,7 +128,8 @@ namespace GHelper { model = results[0]; bios = results[1]; - } else + } + else { model = obj["SMBIOSBIOSVersion"].ToString(); } @@ -114,11 +153,12 @@ namespace GHelper httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip, deflate, br"); httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App"); var json = await httpClient.GetStringAsync(url); + var data = JsonSerializer.Deserialize(json); var groups = data.GetProperty("Result").GetProperty("Obj"); - List skipList = new() { "Armoury Crate & Aura Creator Installer", "MyASUS", "ASUS Smart Display Control", "Aura Wallpaper", "Virtual Pet","ROG Font V1.5" }; + List skipList = new() { "Armoury Crate & Aura Creator Installer", "MyASUS", "ASUS Smart Display Control", "Aura Wallpaper", "Virtual Pet", "ROG Font V1.5" }; List drivers = new(); for (int i = 0; i < groups.GetArrayLength(); i++) @@ -145,6 +185,7 @@ namespace GHelper driver.hardwares = file.GetProperty("HardwareInfoList"); drivers.Add(driver); + Invoke(delegate { string versionText = driver.version.Replace("latest version at the ", ""); @@ -170,6 +211,7 @@ namespace GHelper } } + Invoke(delegate { table.Visible = true; @@ -177,6 +219,7 @@ namespace GHelper PerformLayout(); }); + Dictionary devices = new(); if (type == 0) devices = GetDeviceVersions(); @@ -208,8 +251,13 @@ namespace GHelper { Invoke(delegate { + updatesCount++; label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold); label.ForeColor = colorTurbo; + + labelUpdates.Text = $"{Properties.Strings.NewUpdates}: {updatesCount}"; + labelUpdates.ForeColor = colorTurbo; + labelUpdates.Font = new Font(label.Font, FontStyle.Bold); }); } } @@ -217,6 +265,8 @@ namespace GHelper count++; } + GC.Collect(); + GC.WaitForPendingFinalizers(); } } catch (Exception ex) diff --git a/docs/README.md b/docs/README.md index a991e72c..b8b92e7f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -121,9 +121,15 @@ False positives from Windows Defender (or any other similar system that uses mac #### Where can I find app settings or logs ? You can find them under ``%AppData%\GHelper`` folder. Please include them when posting a new bug-report or issue. +#### App refuses to run on startup / runs without icon in tray on startup +Open app, and uncheck and check again "run on startup". If it still doesn't help (by some reason), you can try to manually edit "GHelper" task in windows Task Scheduler, and add couple of seconds delay to start. + #### How do I uninstall G-helper? G-helper is a single exe, and it doesn't install anything in the system. To remove it - you can simply delete exe :) If you have applied any custom fan profiles or PPTs - before removing I would recommend selecting your favorite performance mode (for example balanced) and clicking "Factory defaults" under Fans + Power. +#### How do I do a hardware reset on a laptop? +This is not related to g-helper anyhow, but all Asus laptops have an option to do a hardware reset that can be handy sometimes. It doesn't touch your data in any way, but resets all main hardware-related things (enables your dGPU, wakes up wifi/bt adapter if it hanged by some reason, etc). To do this reset : Turn OFF laptop. Press and hold "power" button for 30-40 seconds. Then boot normally (it will take a bit longer to boot) + #### What is G-helper ? G-Helper is a lightweight Armoury Crate alternative for Asus laptops. A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.