public AmdGpu(AtiAdlxx.ADLAdapterInfo adapterInfo, ISettings settings)
            : base(adapterInfo.AdapterName.Trim(), new Identifier("gpu-amd", adapterInfo.AdapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
        {
            _adapterIndex = adapterInfo.AdapterIndex;
            BusNumber     = adapterInfo.BusNumber;
            DeviceNumber  = adapterInfo.DeviceNumber;

            _temperatureCore    = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
            _temperatureMemory  = new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
            _temperatureVddc    = new Sensor("GPU VR VDDC", 2, SensorType.Temperature, this, settings);
            _temperatureMvdd    = new Sensor("GPU VR MVDD", 3, SensorType.Temperature, this, settings);
            _temperatureSoC     = new Sensor("GPU VR SoC", 4, SensorType.Temperature, this, settings);
            _temperatureLiquid  = new Sensor("GPU Liquid", 5, SensorType.Temperature, this, settings);
            _temperaturePlx     = new Sensor("GPU PLX", 6, SensorType.Temperature, this, settings);
            _temperatureHotSpot = new Sensor("GPU Hot Spot", 7, SensorType.Temperature, this, settings);

            _coreClock   = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
            _socClock    = new Sensor("GPU SoC", 1, SensorType.Clock, this, settings);
            _memoryClock = new Sensor("GPU Memory", 2, SensorType.Clock, this, settings);

            _fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);

            _coreVoltage   = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
            _memoryVoltage = new Sensor("GPU Memory", 1, SensorType.Voltage, this, settings);
            _socVoltage    = new Sensor("GPU SoC", 2, SensorType.Voltage, this, settings);

            _coreLoad   = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
            _memoryLoad = new Sensor("GPU Memory", 1, SensorType.Load, this, settings);

            _controlSensor = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);

            _powerCore  = new Sensor("GPU Core", 0, SensorType.Power, this, settings);
            _powerPpt   = new Sensor("GPU PPT", 1, SensorType.Power, this, settings);
            _powerSoC   = new Sensor("GPU SoC", 2, SensorType.Power, this, settings);
            _powerTotal = new Sensor("GPU Package", 3, SensorType.Power, this, settings);

            _fullscreenFps = new Sensor("Fullscreen FPS", 0, SensorType.Factor, this, settings);

            if (!Software.OperatingSystem.IsUnix)
            {
                string   convertedPnpString = adapterInfo.PNPString.Replace("\\", "#");
                string[] deviceIdentifiers  = D3DDisplayDevice.GetDeviceIdentifiers();
                if (deviceIdentifiers != null)
                {
                    foreach (string deviceIdentifier in deviceIdentifiers)
                    {
                        if (deviceIdentifier.IndexOf(convertedPnpString, StringComparison.OrdinalIgnoreCase) != -1 &&
                            D3DDisplayDevice.GetDeviceInfoByIdentifier(deviceIdentifier, out D3DDisplayDevice.D3DDeviceInfo deviceInfo))
                        {
                            _windowsDeviceName = deviceIdentifier;

                            int nodeSensorIndex   = 2;
                            int memorySensorIndex = 0;

                            _gpuDedicatedMemoryUsage = new Sensor("D3D Dedicated Memory Used", memorySensorIndex++, SensorType.SmallData, this, settings);
                            _gpuSharedMemoryUsage    = new Sensor("D3D Shared Memory Used", memorySensorIndex, SensorType.SmallData, this, settings);

                            _gpuNodeUsage          = new Sensor[deviceInfo.Nodes.Length];
                            _gpuNodeUsagePrevValue = new long[deviceInfo.Nodes.Length];
                            _gpuNodeUsagePrevTick  = new DateTime[deviceInfo.Nodes.Length];

                            foreach (D3DDisplayDevice.D3DDeviceNodeInfo node in deviceInfo.Nodes.OrderBy(x => x.Name))
                            {
                                _gpuNodeUsage[node.Id]          = new Sensor(node.Name, nodeSensorIndex++, SensorType.Load, this, settings);
                                _gpuNodeUsagePrevValue[node.Id] = node.RunningTime;
                                _gpuNodeUsagePrevTick[node.Id]  = node.QueryTime;
                            }

                            break;
                        }
                    }
                }
            }

            int supported = 0;
            int enabled   = 0;
            int version   = 0;

            if (AtiAdlxx.ADL2_Adapter_FrameMetrics_Caps(_context, _adapterIndex, ref supported) == AtiAdlxx.ADLStatus.ADL_OK)
            {
                if (supported == AtiAdlxx.ADL_TRUE && AtiAdlxx.ADL2_Adapter_FrameMetrics_Start(_context, _adapterIndex, 0) == AtiAdlxx.ADLStatus.ADL_OK)
                {
                    _frameMetricsStarted = true;
                    _fullscreenFps.Value = -1;
                    ActivateSensor(_fullscreenFps);
                }
            }

            if (AtiAdlxx.ADL_Overdrive_Caps(_adapterIndex, ref supported, ref enabled, ref version) == AtiAdlxx.ADLStatus.ADL_OK)
            {
                _overdriveApiSupported    = supported == AtiAdlxx.ADL_TRUE;
                _currentOverdriveApiLevel = version;
            }
            else
            {
                _currentOverdriveApiLevel = -1;
            }

            if (_currentOverdriveApiLevel >= 5)
            {
                if (AtiAdlxx.ADL2_Main_Control_Create(AtiAdlxx.Main_Memory_Alloc, _adapterIndex, ref _context) != AtiAdlxx.ADLStatus.ADL_OK)
                {
                    _context = IntPtr.Zero;
                }
            }

            AtiAdlxx.ADLFanSpeedInfo fanSpeedInfo = new();
            if (AtiAdlxx.ADL_Overdrive5_FanSpeedInfo_Get(_adapterIndex, 0, ref fanSpeedInfo) != AtiAdlxx.ADLStatus.ADL_OK)
            {
                fanSpeedInfo.MaxPercent = 100;
                fanSpeedInfo.MinPercent = 0;
            }

            _fanControl = new Control(_controlSensor, settings, fanSpeedInfo.MinPercent, fanSpeedInfo.MaxPercent);
            _fanControl.ControlModeChanged          += ControlModeChanged;
            _fanControl.SoftwareControlValueChanged += SoftwareControlValueChanged;
            ControlModeChanged(_fanControl);
            _controlSensor.Control = _fanControl;

            Update();
        }
        public AmdGpu(string name, int adapterIndex, int busNumber, int deviceNumber, ISettings settings)
            : base(name, new Identifier("gpu-amd", adapterIndex.ToString(CultureInfo.InvariantCulture)), settings)
        {
            _adapterIndex = adapterIndex;
            BusNumber     = busNumber;
            DeviceNumber  = deviceNumber;

            _temperatureCore    = new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
            _temperatureMemory  = new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
            _temperatureVddc    = new Sensor("GPU VR VDDC", 2, SensorType.Temperature, this, settings);
            _temperatureMvdd    = new Sensor("GPU VR MVDD", 3, SensorType.Temperature, this, settings);
            _temperatureSoC     = new Sensor("GPU VR SoC", 4, SensorType.Temperature, this, settings);
            _temperatureLiquid  = new Sensor("GPU Liquid", 5, SensorType.Temperature, this, settings);
            _temperaturePlx     = new Sensor("GPU PLX", 6, SensorType.Temperature, this, settings);
            _temperatureHotSpot = new Sensor("GPU Hot Spot", 7, SensorType.Temperature, this, settings);

            _coreClock   = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
            _socClock    = new Sensor("GPU SoC", 1, SensorType.Clock, this, settings);
            _memoryClock = new Sensor("GPU Memory", 2, SensorType.Clock, this, settings);

            _fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);

            _coreVoltage   = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
            _memoryVoltage = new Sensor("GPU Memory", 1, SensorType.Voltage, this, settings);
            _socVoltage    = new Sensor("GPU SoC", 2, SensorType.Voltage, this, settings);

            _coreLoad   = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
            _memoryLoad = new Sensor("GPU Memory", 1, SensorType.Load, this, settings);

            _controlSensor = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);

            _powerCore  = new Sensor("GPU Core", 0, SensorType.Power, this, settings);
            _powerPpt   = new Sensor("GPU PPT", 1, SensorType.Power, this, settings);
            _powerSoC   = new Sensor("GPU SoC", 2, SensorType.Power, this, settings);
            _powerTotal = new Sensor("GPU Package", 3, SensorType.Power, this, settings);

            _fullscreenFPS = new Sensor("Fullscreen FPS", 0, SensorType.Factor, this, settings);

            int supported = 0;
            int enabled   = 0;
            int version   = 0;

            if (AtiAdlxx.ADL2_Adapter_FrameMetrics_Caps(_context, _adapterIndex, ref supported) == AtiAdlxx.ADLStatus.ADL_OK)
            {
                if (supported == AtiAdlxx.ADL_TRUE && AtiAdlxx.ADL2_Adapter_FrameMetrics_Start(_context, _adapterIndex, 0) == AtiAdlxx.ADLStatus.ADL_OK)
                {
                    _framemetricsStarted = true;
                    _fullscreenFPS.Value = -1;
                    ActivateSensor(_fullscreenFPS);
                }
            }

            if (AtiAdlxx.ADL_Overdrive_Caps(1, ref supported, ref enabled, ref version) == AtiAdlxx.ADLStatus.ADL_OK)
            {
                _overdriveApiSupported    = supported == AtiAdlxx.ADL_TRUE;
                _currentOverdriveApiLevel = version;
            }
            else
            {
                _currentOverdriveApiLevel = -1;
            }

            if (_currentOverdriveApiLevel >= 6)
            {
                if (AtiAdlxx.ADL2_Main_Control_Create(AtiAdlxx.Main_Memory_Alloc, adapterIndex, ref _context) == AtiAdlxx.ADLStatus.ADL_OK)
                {
                    _context = IntPtr.Zero;
                }
            }

            AtiAdlxx.ADLFanSpeedInfo fanSpeedInfo = new AtiAdlxx.ADLFanSpeedInfo();
            if (AtiAdlxx.ADL_Overdrive5_FanSpeedInfo_Get(adapterIndex, 0, ref fanSpeedInfo) != AtiAdlxx.ADLStatus.ADL_OK)
            {
                fanSpeedInfo.MaxPercent = 100;
                fanSpeedInfo.MinPercent = 0;
            }

            _fanControl = new Control(_controlSensor, settings, fanSpeedInfo.MinPercent, fanSpeedInfo.MaxPercent);
            _fanControl.ControlModeChanged          += ControlModeChanged;
            _fanControl.SoftwareControlValueChanged += SoftwareControlValueChanged;
            ControlModeChanged(_fanControl);
            _controlSensor.Control = _fanControl;
            Update();
        }