Ejemplo n.º 1
0
        public override void Update()
        {
            if (context != IntPtr.Zero && overdriveVersion >= 8 &&
                ADL.ADL2_New_QueryPMLogData_Get(context, adapterIndex,
                                                out var data) == ADL.ADL_OK)
            {
                GetPMLog(data, ADLSensorType.TEMPERATURE_EDGE, temperatureCore);
                GetPMLog(data, ADLSensorType.TEMPERATURE_MEM, temperatureMemory);
                GetPMLog(data, ADLSensorType.TEMPERATURE_VRVDDC, temperatureVrmCore);
                GetPMLog(data, ADLSensorType.TEMPERATURE_VRMVDD, temperatureVrmMemory);
                //GetPMLog(data, ADLSensorType.TEMPERATURE_VRMVDD0, temperatureVrmMemory0);
                //GetPMLog(data, ADLSensorType.TEMPERATURE_VRMVDD1, temperatureVrmMemory1);
                GetPMLog(data, ADLSensorType.TEMPERATURE_VRSOC, temperatureVrmSoc);
                GetPMLog(data, ADLSensorType.TEMPERATURE_LIQUID, temperatureLiquid);
                GetPMLog(data, ADLSensorType.TEMPERATURE_PLX, temperaturePlx);
                GetPMLog(data, ADLSensorType.TEMPERATURE_HOTSPOT, temperatureHotSpot);
                GetPMLog(data, ADLSensorType.GFX_POWER, powerCore);
                GetPMLog(data, ADLSensorType.ASIC_POWER, powerTotal);
                GetPMLog(data, ADLSensorType.SOC_POWER, powerSoc);
                GetPMLog(data, ADLSensorType.FAN_RPM, fan);
                GetPMLog(data, ADLSensorType.CLK_GFXCLK, coreClock);
                GetPMLog(data, ADLSensorType.CLK_MEMCLK, memoryClock);
                GetPMLog(data, ADLSensorType.CLK_SOCCLK, socClock);
                GetPMLog(data, ADLSensorType.GFX_VOLTAGE, coreVoltage, 0.001f);
                GetPMLog(data, ADLSensorType.MEM_VOLTAGE, memoryVoltage, 0.001f);
                GetPMLog(data, ADLSensorType.SOC_VOLTAGE, socVoltage, 0.001f);
                GetPMLog(data, ADLSensorType.INFO_ACTIVITY_GFX, coreLoad);
                GetPMLog(data, ADLSensorType.INFO_ACTIVITY_MEM, memoryControllerLoad);
                GetPMLog(data, ADLSensorType.FAN_PERCENTAGE, controlSensor);

                if (sensorConfig.GetSensorEvaluate(this.memoryUsed.IdentifierString))
                {
                    if (ADL.ADL2_Adapter_VRAMUsage_Get(context, adapterIndex, out int vramUsage) == ADL.ADL_OK)
                    {
                        this.memoryUsed.Value = vramUsage / 1024f;
                        ActivateSensor(this.memoryUsed);
                    }
                }
            }
            else
            {
                if (context != IntPtr.Zero && overdriveVersion >= 7)
                {
                    GetODNTemperature(ADLODNTemperatureType.CORE, temperatureCore);
                    GetODNTemperature(ADLODNTemperatureType.MEMORY, temperatureMemory);
                    GetODNTemperature(ADLODNTemperatureType.VRM_CORE, temperatureVrmCore);
                    GetODNTemperature(ADLODNTemperatureType.VRM_MEMORY, temperatureVrmMemory);
                    GetODNTemperature(ADLODNTemperatureType.LIQUID, temperatureLiquid);
                    GetODNTemperature(ADLODNTemperatureType.PLX, temperaturePlx);
                    GetODNTemperature(ADLODNTemperatureType.HOTSPOT, temperatureHotSpot);
                }
                else
                {
                    ADLTemperature adlt = new ADLTemperature();
                    bool           evalTemperatureCore = sensorConfig.GetSensorEvaluate(temperatureCore.IdentifierString);
                    if (evalTemperatureCore && (ADL.ADL_Overdrive5_Temperature_Get(adapterIndex, 0, ref adlt)
                                                == ADL.ADL_OK))
                    {
                        temperatureCore.Value = 0.001f * adlt.Temperature;
                        ActivateSensor(temperatureCore);
                    }
                    else
                    {
                        temperatureCore.Value = null;
                    }
                }

                if (context != IntPtr.Zero && overdriveVersion >= 6)
                {
                    GetOD6Power(ADLODNCurrentPowerType.TOTAL_POWER, powerTotal);
                    GetOD6Power(ADLODNCurrentPowerType.CHIP_POWER, powerCore);
                    GetOD6Power(ADLODNCurrentPowerType.PPT_POWER, powerPpt);
                    GetOD6Power(ADLODNCurrentPowerType.SOCKET_POWER, powerSocket);
                }

                ADLFanSpeedValue adlf = new ADLFanSpeedValue
                {
                    SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_RPM
                };

                bool evalFan = sensorConfig.GetSensorEvaluate(fan.IdentifierString);
                if (evalFan && (ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref adlf)
                                == ADL.ADL_OK))
                {
                    fan.Value = adlf.FanSpeed;
                    ActivateSensor(fan);
                }
                else
                {
                    fan.Value = null;
                }

                adlf = new ADLFanSpeedValue
                {
                    SpeedType = ADL.ADL_DL_FANCTRL_SPEED_TYPE_PERCENT
                };

                bool evalControlSensor = sensorConfig.GetSensorEvaluate(controlSensor.IdentifierString);
                if (evalControlSensor && (ADL.ADL_Overdrive5_FanSpeed_Get(adapterIndex, 0, ref adlf)
                                          == ADL.ADL_OK))
                {
                    // ADL bug: percentage is not 0 when rpm is 0
                    controlSensor.Value = fan.Value == 0 ? 0 : adlf.FanSpeed;
                    ActivateSensor(controlSensor);
                }
                else
                {
                    controlSensor.Value = null;
                }

                ADLPMActivity adlp = new ADLPMActivity();
                if (ADL.ADL_Overdrive5_CurrentActivity_Get(adapterIndex, ref adlp) == ADL.ADL_OK)
                {
                    bool evalCoreClock = sensorConfig.GetSensorEvaluate(coreClock.IdentifierString);
                    if (adlp.EngineClock > 0 && evalCoreClock)
                    {
                        coreClock.Value = 0.01f * adlp.EngineClock;
                        ActivateSensor(coreClock);
                    }
                    else
                    {
                        coreClock.Value = null;
                    }

                    bool evalMemoryClock = sensorConfig.GetSensorEvaluate(memoryClock.IdentifierString);
                    if (adlp.MemoryClock > 0 && evalMemoryClock)
                    {
                        memoryClock.Value = 0.01f * adlp.MemoryClock;
                        ActivateSensor(memoryClock);
                    }
                    else
                    {
                        memoryClock.Value = null;
                    }

                    bool evalCoreVoltage = sensorConfig.GetSensorEvaluate(coreVoltage.IdentifierString);
                    if (adlp.Vddc > 0 && evalCoreVoltage)
                    {
                        coreVoltage.Value = 0.001f * adlp.Vddc;
                        ActivateSensor(coreVoltage);
                    }
                    else
                    {
                        coreVoltage.Value = null;
                    }

                    if (sensorConfig.GetSensorEvaluate(coreLoad.IdentifierString))
                    {
                        coreLoad.Value = Math.Min(adlp.ActivityPercent, 100);
                        ActivateSensor(coreLoad);
                    }
                }
                else
                {
                    coreClock.Value   = null;
                    memoryClock.Value = null;
                    coreVoltage.Value = null;
                    coreLoad.Value    = null;
                }
            }

            // update VRAM usage
            if (dedicatedVramUsagePerformCounter != null)
            {
                try
                {
                    if (sensorConfig.GetSensorEvaluate(memoryUsageDedicated.IdentifierString))
                    {
                        memoryUsageDedicated.Value = dedicatedVramUsagePerformCounter.NextValue() / SCALE;
                        ActivateSensor(memoryUsageDedicated);
                    }
                    else
                    {
                        memoryUsageDedicated.Value = null;
                    }
                }
                catch { memoryUsageDedicated.Value = null; }
            }

            if (sharedVramUsagePerformCounter != null)
            {
                try
                {
                    if (sensorConfig.GetSensorEvaluate(memoryUsageShared.IdentifierString))
                    {
                        memoryUsageShared.Value = (float)sharedVramUsagePerformCounter.NextValue() / SCALE;
                        ActivateSensor(memoryUsageShared);
                    }
                    else
                    {
                        memoryUsageShared.Value = null;
                    }
                }
                catch { memoryUsageShared.Value = null; }
            }

            try
            {
                if (sensorConfig.GetSensorEvaluate(processMemoryUsageDedicated.IdentifierString))
                {
                    lock (_performanceCounterLock)
                    {
                        processMemoryUsageDedicated.Value = dedicatedVramUsageProcessPerformCounter == null
                        ? 0f : (float)dedicatedVramUsageProcessPerformCounter.NextValue() / SCALE;
                    }
                    ActivateSensor(processMemoryUsageDedicated);
                }
                else
                {
                    processMemoryUsageDedicated.Value = null;
                }
            }
            catch { processMemoryUsageDedicated.Value = null; }

            try
            {
                if (sensorConfig.GetSensorEvaluate(processMemoryUsageShared.IdentifierString))
                {
                    lock (_performanceCounterLock)
                    {
                        processMemoryUsageShared.Value = sharedVramUsageProcessPerformCounter == null
                        ? 0f : (float)sharedVramUsageProcessPerformCounter.NextValue() / SCALE;
                    }
                    ActivateSensor(processMemoryUsageShared);
                }
                else
                {
                    processMemoryUsageShared.Value = null;
                }
            }
            catch { processMemoryUsageShared.Value = null; }
        }