feat: Add PreferredGpu setting for multi-GPU systems (dGPU/iGPU selection)#409
Open
haihaihailailo wants to merge 9 commits intoDiorser:masterfrom
Open
feat: Add PreferredGpu setting for multi-GPU systems (dGPU/iGPU selection)#409haihaihailailo wants to merge 9 commits intoDiorser:masterfrom
haihaihailailo wants to merge 9 commits intoDiorser:masterfrom
Conversation
…ortunities Optimize HardwareScanner list materialization and sorting
…ortunities-j4m3nz Add packaging script and improve HardwareScanner caching and GPU/fan/mobo detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
多显卡笔记本(AMD/Intel 核显 + NVIDIA 独显的组合)当前无法选择 GPU 监控项显示哪块显卡。在我的设备上(AMD Ryzen 7 H 255 + Radeon 780M + NVIDIA RTX 5060 Laptop,独显直连模式),GPU 分组默认锁定 AMD 核显,无法读取到独显数据。
「系统硬件详情」面板能正常识别两块显卡的所有传感器,说明 LibreHardwareMonitorLib 已经拿到了数据,只是上层没提供切换入口。
实现方案
新增
Settings.PreferredGpu配置字段,完全参照现有PreferredDisk/PreferredCpuFan等首选设备字段的模式。在「设置 → 硬件与系统」面板增加「首选显卡」下拉框,UI 实现照抄现有磁盘/网卡下拉。核心过滤逻辑放在
SensorMap.Rebuild中:遍历硬件时,若PreferredGpu非空,跳过名称不匹配的 GPU 硬件,确保所有GPU.*传感器键都绑定到用户指定的显卡。HardwareValueProvider.OnUpdateTickStarted检测到PreferredGpu变更时,触发SensorMap.Rebuild并重新PreCacheAllSensors,用户改变选择后无需重启软件即可生效。改动文件
src/Core/Settings.cs- 新增PreferredGpu字段src/System/HardwareServices/HardwareScanner.cs- 新增ListAllGpus方法src/System/HardwareServices/SensorMap.cs- Rebuild 支持按 PreferredGpu 过滤 + 新增Invalidate()方法src/System/HardwareServices/HardwareValueProvider.cs- 检测 GPU 变更并触发重建src/System/HardwareMonitor.cs- 暴露ListAllGpus静态方法src/UI/Settings/SystemHardwarPage.cs- 新增 GPU 下拉框resources/lang/zh.json/en.json- 新增Menu.GpuSource翻译兼容性
""= 自动模式 = 原有行为,对现有用户无感知SETTINGS_README_DEV.md的 Draft-Commit 规范(仅加配置字段 + UI 绑定,SettingsChanger.Merge会自动通过反射处理新字段)测试
在 AMD 780M + RTX 5060 Laptop 笔记本上验证:
对比任务管理器和其它监控软件的 NVIDIA GPU 数据一致(排除采样时刻差异)。