From 43291667a6cb9e93ea00c874aa6c1a637a70d43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Fri, 4 Dec 2026 06:32:51 -0700 Subject: [PATCH] feat(ui,host): default host memory specs, dedupe Vulkan GPUs Sync the host's SMBIOS Type 17 memory spec by default and drop the toggle: the frontend switch, the App.SetSyncHostMemorySMBIOS binding and the sync_host_memory_smbios config field are gone, so macOS About This Mac always reports the host's real RAM speed and generation. A manual -smbios type=17 argument still wins, and a host without a readable speed keeps the default. Deduplicate repeated Vulkan physical devices on the Runtime page when several ICD manifests enumerate the same GPU, preferring the healthiest/newest probe while keeping genuinely distinct adapters. Move Appearance & language to the top of Settings. model: deepseek/deepseek-v4.1-flash agent: lead (DeepSeek Harness) --- changes/dedupe-vulkan-gpu-entries.json | 7 ++ changes/ui-polish-update-cache-and-speed.json | 4 +- frontend/src/components/AppSettingsPage.tsx | 107 +++++++----------- frontend/src/i18n/domains/settings.gen.ts | 6 - frontend/src/i18n/keys.gen.ts | 3 - frontend/wailsjs/go/app/App.d.ts | 2 - frontend/wailsjs/go/app/App.js | 4 - frontend/wailsjs/go/models.ts | 2 - internal/app/app.go | 5 - internal/app/dataroot_aslr_test.go | 4 +- internal/app/runtime_selection_test.go | 16 +-- internal/config/config.go | 8 +- internal/host/gpu_compat.go | 91 ++++++++++++++- internal/host/host_test.go | 45 ++++++++ internal/macos/macosdriver/prepare.go | 8 +- .../macos/macosdriver/prepare_smbios_test.go | 23 ++-- internal/macos/startprep/startprep.go | 2 +- internal/runtime/selection_test.go | 4 +- locales/en-US/settings.json | 3 - locales/zh-CN/settings.json | 3 - 20 files changed, 209 insertions(+), 138 deletions(-) create mode 100644 changes/dedupe-vulkan-gpu-entries.json diff --git a/changes/dedupe-vulkan-gpu-entries.json b/changes/dedupe-vulkan-gpu-entries.json new file mode 100644 index 0000000..2a473aa --- /dev/null +++ b/changes/dedupe-vulkan-gpu-entries.json @@ -0,0 +1,7 @@ +{ + "group": "fixes", + "order": 0, + "authors": ["Nwflower"], + "zh": "修复宿主机存在多份 Vulkan ICD 驱动清单时,内核页重复显示同一块显卡且缺失驱动版本号的问题。", + "en": "Deduplicate repeated Vulkan physical device entries on the Runtime page when multiple ICD manifests are registered for the same GPU." +} diff --git a/changes/ui-polish-update-cache-and-speed.json b/changes/ui-polish-update-cache-and-speed.json index ab4fcef..01b93c1 100644 --- a/changes/ui-polish-update-cache-and-speed.json +++ b/changes/ui-polish-update-cache-and-speed.json @@ -2,6 +2,6 @@ "group": "improvements", "order": 0, "authors": ["Nwflower"], - "zh": "下载速度低于 1 MB/s 时改以 KB/s 显示,精简关于页社区与更新通道文案,并将更新检查按通道缓存 5 分钟,切换更新通道时不再禁用控件。", - "en": "Display download speeds below 1 MB/s in KB/s, tighten About page and update channel copy, cache update checks per channel for 5 minutes, and keep the update channel selector interactive while switching." + "zh": "下载速度低于 1 MB/s 时改以 KB/s 显示,精简关于页与更新通道文案,默认同步宿主机内存规格并将外观与语言设置分组置顶,更新检查按通道缓存 5 分钟且切换通道时不再禁用控件。", + "en": "Display download speeds below 1 MB/s in KB/s, tighten About page and update channel copy, sync host memory SMBIOS specs by default and move Appearance & language to the top of Settings, cache update checks per channel for 5 minutes, and keep the update channel selector interactive while switching." } diff --git a/frontend/src/components/AppSettingsPage.tsx b/frontend/src/components/AppSettingsPage.tsx index 7de34b2..01e770a 100644 --- a/frontend/src/components/AppSettingsPage.tsx +++ b/frontend/src/components/AppSettingsPage.tsx @@ -123,9 +123,6 @@ export const AppSettingsPage: React.FC = ({ const pcoreOpt = findOptimization(optimizations, 'pcore_pin') const missingFontScript = state.missing_font_hint || '' - const memSpecLabel = host.memory_spec?.speed_mhz - ? `${host.memory_spec.speed_mhz} MHz${host.memory_spec.type_name ? ` ${host.memory_spec.type_name}` : ''}` - : '' const guard = (fn: () => Promise) => async () => { try { @@ -491,6 +488,49 @@ export const AppSettingsPage: React.FC = ({

{tr('sidebarSettings')}

+
+
{tr('settingsAppearance')}
+
+
+
+
{tr('themeLabel')}
+ {(!canDark || !canLight) && ( +
{tr(!canDark ? 'themePluginDarkDisabled' : 'themePluginLightDisabled')}
+ )} +
+
+ +
+
+
+
+
{tr('language')}
+
{tr('languageSub')}
+ {missingFontScript && ( +
{tr('fontMissingFoDHint', { script: missingFontScript })}
+ )} +
+
+ +
+
+
+
+
{tr('settingsGeneral')}
@@ -524,24 +564,6 @@ export const AppSettingsPage: React.FC = ({ />
-
-
-
{tr('syncHostMemorySMBIOS')}
-
- {memSpecLabel - ? tr('syncHostMemorySMBIOSSub', { spec: memSpecLabel }) - : tr('syncHostMemorySMBIOSUnavailable')} -
-
-
- guard(() => api.SetSyncHostMemorySMBIOS(checked))()} - /> -
-
{tr('minimizeToTray')}
@@ -826,49 +848,6 @@ export const AppSettingsPage: React.FC = ({
-
-
{tr('settingsAppearance')}
-
-
-
-
{tr('themeLabel')}
- {(!canDark || !canLight) && ( -
{tr(!canDark ? 'themePluginDarkDisabled' : 'themePluginLightDisabled')}
- )} -
-
- -
-
-
-
-
{tr('language')}
-
{tr('languageSub')}
- {missingFontScript && ( -
{tr('fontMissingFoDHint', { script: missingFontScript })}
- )} -
-
- -
-
-
-
- {pluginViews.length > 0 && (
{tr('sidebarPlugins')}
diff --git a/frontend/src/i18n/domains/settings.gen.ts b/frontend/src/i18n/domains/settings.gen.ts index 9f4137b..ea30f84 100644 --- a/frontend/src/i18n/domains/settings.gen.ts +++ b/frontend/src/i18n/domains/settings.gen.ts @@ -491,9 +491,6 @@ export const settingsZh: Record = { "storageInstallers": "镜像", "storageRuntimes": "Reims-Go", "storageVMs": "虚拟机文件", - "syncHostMemorySMBIOS": "同步宿主机内存规格", - "syncHostMemorySMBIOSSub": "在 macOS「关于本机」中显示宿主机真实内存频率与代数(当前:{spec}),下次启动生效", - "syncHostMemorySMBIOSUnavailable": "未能从宿主机 SMBIOS 读取物理内存频率,虚拟机将保持默认的 2666 MHz DDR4", "targetDisplayDisconnectedOption": "已断开 · 回退至主显示器", "targetDisplayFallbackHint": "已保存的「{name}」当前未连接,将回退至主显示器", "targetDisplayHint": "目标显示器:{name}({w}×{h},{scale}% 缩放)", @@ -1030,9 +1027,6 @@ export const settingsEn: Record = { "storageInstallers": "Images", "storageRuntimes": "Reims-Go", "storageVMs": "VM files", - "syncHostMemorySMBIOS": "Sync host memory specs", - "syncHostMemorySMBIOSSub": "Show the host's actual memory speed and generation ({spec}) in macOS About This Mac; applies on next start", - "syncHostMemorySMBIOSUnavailable": "Could not read host SMBIOS memory speed; VMs keep the default 2666 MHz DDR4", "targetDisplayDisconnectedOption": "Disconnected · using primary", "targetDisplayFallbackHint": "Saved {name} is disconnected; falling back to the primary display", "targetDisplayHint": "Target display: {name} ({w}×{h} at {scale}%)", diff --git a/frontend/src/i18n/keys.gen.ts b/frontend/src/i18n/keys.gen.ts index 1701984..6a69726 100644 --- a/frontend/src/i18n/keys.gen.ts +++ b/frontend/src/i18n/keys.gen.ts @@ -1063,9 +1063,6 @@ export type I18nKey = | "suspendedNoticeDescWithTime" | "suspendedNoticeTitle" | "suspendedSettingsHint" - | "syncHostMemorySMBIOS" - | "syncHostMemorySMBIOSSub" - | "syncHostMemorySMBIOSUnavailable" | "targetDisplayDisconnectedOption" | "targetDisplayFallbackHint" | "targetDisplayHint" diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts index 3bab159..9f233b2 100644 --- a/frontend/wailsjs/go/app/App.d.ts +++ b/frontend/wailsjs/go/app/App.d.ts @@ -272,8 +272,6 @@ export function SetQEMUASLR(arg1:boolean):Promise; export function SetRuntimeChannel(arg1:string):Promise; -export function SetSyncHostMemorySMBIOS(arg1:boolean):Promise; - export function SetVMAffinity(arg1:string,arg2:string,arg3:app.VMAffinityUpdate):Promise; export function SetVMDisplay(arg1:string,arg2:string,arg3:string):Promise; diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js index 1dc4c7c..4638143 100644 --- a/frontend/wailsjs/go/app/App.js +++ b/frontend/wailsjs/go/app/App.js @@ -522,10 +522,6 @@ export function SetRuntimeChannel(arg1) { return window['go']['app']['App']['SetRuntimeChannel'](arg1); } -export function SetSyncHostMemorySMBIOS(arg1) { - return window['go']['app']['App']['SetSyncHostMemorySMBIOS'](arg1); -} - export function SetVMAffinity(arg1, arg2, arg3) { return window['go']['app']['App']['SetVMAffinity'](arg1, arg2, arg3); } diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 6b71488..ebcb402 100644 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -812,7 +812,6 @@ export namespace config { qemu_aslr?: boolean; app_update_channel?: string; minimize_to_tray?: boolean; - sync_host_memory_smbios?: boolean; host_dns_mode?: string; host_dns_doh_url?: string; enable_hypervisor_switch?: boolean; @@ -834,7 +833,6 @@ export namespace config { this.qemu_aslr = source["qemu_aslr"]; this.app_update_channel = source["app_update_channel"]; this.minimize_to_tray = source["minimize_to_tray"]; - this.sync_host_memory_smbios = source["sync_host_memory_smbios"]; this.host_dns_mode = source["host_dns_mode"]; this.host_dns_doh_url = source["host_dns_doh_url"]; this.enable_hypervisor_switch = source["enable_hypervisor_switch"]; diff --git a/internal/app/app.go b/internal/app/app.go index 381277d..6421575 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -471,10 +471,6 @@ func (a *App) SetMinimizeToTray(enabled bool) error { return a.setPreference(func(cfg *config.Config) { cfg.MinimizeToTray = &enabled }) } -func (a *App) SetSyncHostMemorySMBIOS(enabled bool) error { - return a.setPreference(func(cfg *config.Config) { cfg.SyncHostMemorySMBIOS = enabled }) -} - // showMainWindow restores and focuses the Wails window from the system tray. func (a *App) showMainWindow() { if a.ctx == nil { @@ -744,7 +740,6 @@ func (a *App) setDataRoot(dir string, syncPolicy func(context.Context, string, s nextCfg.RuntimeChannel = cur.RuntimeChannel nextCfg.AppUpdateChannel = cur.AppUpdateChannel nextCfg.MinimizeToTray = cur.MinimizeToTray - nextCfg.SyncHostMemorySMBIOS = cur.SyncHostMemorySMBIOS nextCfg.EnableHypervisorSwitch = cur.EnableHypervisorSwitch nextCfg.HostDNSMode, nextCfg.HostDNSDoHURL = cur.HostDNSMode, cur.HostDNSDoHURL nextCfg.FullscreenHotkeyEnabled = cur.FullscreenHotkeyEnabled diff --git a/internal/app/dataroot_aslr_test.go b/internal/app/dataroot_aslr_test.go index 290c020..ae47cb9 100644 --- a/internal/app/dataroot_aslr_test.go +++ b/internal/app/dataroot_aslr_test.go @@ -35,13 +35,13 @@ func TestDataRootSwitchCarriesASLRAndCleansSource(t *testing.T) { if _, err := a.SetFullscreenHotkey(FullscreenHotkeyConfig{Enabled: true, Hotkey: "F9"}); err != nil { return err } - return a.SetSyncHostMemorySMBIOS(true) + return a.SetMinimizeToTray(false) }) if err != nil || calls != 1 { t.Fatalf("switch: calls=%d err=%v", calls, err) } stored, err := config.LoadExisting(filepath.Join(target, "reims-go.json")) - if err != nil || !stored.QEMUASLR || !stored.SyncHostMemorySMBIOS || a.cfg.DataRoot != target { + if err != nil || !stored.QEMUASLR || stored.MinimizeToTray == nil || *stored.MinimizeToTray || a.cfg.DataRoot != target { t.Fatalf("new config: %+v, %v", stored, err) } if !stored.FullscreenHotkeyEnabled || stored.FullscreenHotkey != "F9" { diff --git a/internal/app/runtime_selection_test.go b/internal/app/runtime_selection_test.go index ab179d4..b663196 100644 --- a/internal/app/runtime_selection_test.go +++ b/internal/app/runtime_selection_test.go @@ -66,14 +66,14 @@ func TestRuntimeConfigFollowsExternalSelection(t *testing.T) { if got.ActiveRuntime != "backup" || !got.QEMUASLR { t.Fatalf("desktop reads stale selection: %+v", got) } - if err := a.SetSyncHostMemorySMBIOS(true); err != nil { + if err := a.SetMinimizeToTray(false); err != nil { t.Fatal(err) } saved, err := config.LoadExisting(filepath.Join(dir, "reims-go.json")) if err != nil { t.Fatal(err) } - if saved.ActiveRuntime != "backup" || !saved.QEMUASLR || !saved.SyncHostMemorySMBIOS { + if saved.ActiveRuntime != "backup" || !saved.QEMUASLR || saved.MinimizeToTray == nil || *saved.MinimizeToTray { t.Fatalf("saving an unrelated setting lost the selection: %+v", saved) } } @@ -85,7 +85,7 @@ func TestPreferencesDoNotOverwriteDamagedConfig(t *testing.T) { if err := os.WriteFile(path, []byte("{"), 0o600); err != nil { t.Fatal(err) } - if err := a.SetSyncHostMemorySMBIOS(true); err == nil { + if err := a.SetQEMUASLR(true); err == nil { t.Fatal("saved preferences over an unreadable selection") } if data, err := os.ReadFile(path); err != nil || string(data) != "{" { @@ -100,7 +100,7 @@ func TestConfigWaitDoesNotBlockApp(t *testing.T) { }{ {"ASLR", func(a *App) error { return a.SetQEMUASLR(true) }}, {"runtime", func(a *App) error { return a.UseRuntime("backup") }}, - {"preference", func(a *App) error { return a.SetSyncHostMemorySMBIOS(true) }}, + {"preference", func(a *App) error { return a.SetMinimizeToTray(false) }}, } { t.Run(tc.name, func(t *testing.T) { cfg := &config.Config{DataRoot: t.TempDir()} @@ -129,7 +129,7 @@ func TestConfigWaitDoesNotBlockApp(t *testing.T) { if err := <-done; err == nil || !available { t.Fatalf("global lock available = %v, save error = %v", available, err) } - if a.cfg.QEMUASLR || a.cfg.ActiveRuntime != "" || a.cfg.SyncHostMemorySMBIOS { + if a.cfg.QEMUASLR || a.cfg.ActiveRuntime != "" || (a.cfg.MinimizeToTray != nil && !*a.cfg.MinimizeToTray) { t.Fatalf("failed save published %+v", a.cfg) } }) @@ -158,7 +158,7 @@ func TestConcurrentSelectionAndPreferenceSurvive(t *testing.T) { }) }() synctest.Wait() - if err := a.SetSyncHostMemorySMBIOS(true); err != nil { + if err := a.SetMinimizeToTray(false); err != nil { t.Fatal(err) } close(resume) @@ -166,10 +166,10 @@ func TestConcurrentSelectionAndPreferenceSurvive(t *testing.T) { t.Fatal(err) } saved, err := config.LoadExisting(filepath.Join(dir, "reims-go.json")) - if err != nil || saved.ActiveRuntime != "backup" || !saved.QEMUASLR || !saved.SyncHostMemorySMBIOS { + if err != nil || saved.ActiveRuntime != "backup" || !saved.QEMUASLR || saved.MinimizeToTray == nil || *saved.MinimizeToTray { t.Fatalf("concurrent updates lost: %+v, %v", saved, err) } - if a.cfg.ActiveRuntime != saved.ActiveRuntime || !a.cfg.QEMUASLR || !a.cfg.SyncHostMemorySMBIOS { + if a.cfg.ActiveRuntime != saved.ActiveRuntime || !a.cfg.QEMUASLR || a.cfg.MinimizeToTray == nil || *a.cfg.MinimizeToTray { t.Fatalf("in-memory settings diverged: %+v", a.cfg) } }) diff --git a/internal/config/config.go b/internal/config/config.go index 7fe4ee2..187ccfb 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -27,12 +27,8 @@ type Config struct { AppUpdateChannel string `json:"app_update_channel,omitempty"` // MinimizeToTray keeps Reims-Go running in the Windows system tray when the // main window is closed so Guest Tools bridges stay alive. Defaults to true. - MinimizeToTray *bool `json:"minimize_to_tray,omitempty"` - // SyncHostMemorySMBIOS overrides QEMU's default SMBIOS Type 17 memory spec - // (2666 MHz DDR4) with the host's physical memory speed and generation so - // macOS About This Mac reports the host's real RAM frequency. Defaults to false. - SyncHostMemorySMBIOS bool `json:"sync_host_memory_smbios,omitempty"` - HostDNSMode string `json:"host_dns_mode,omitempty"` + MinimizeToTray *bool `json:"minimize_to_tray,omitempty"` + HostDNSMode string `json:"host_dns_mode,omitempty"` HostDNSDoHURL string `json:"host_dns_doh_url,omitempty"` // EnableHypervisorSwitch unlocks the Hyper-V / WHPX boot launch switch in // Settings for users who alternate with exclusive-mode VMware. Off by diff --git a/internal/host/gpu_compat.go b/internal/host/gpu_compat.go index 8e2ee3f..fcf0edd 100644 --- a/internal/host/gpu_compat.go +++ b/internal/host/gpu_compat.go @@ -206,27 +206,56 @@ func EvaluateGPUCompat(g GPUInfo, probe *VulkanDeviceProbe) GPUInfo { // compatibility grades. func MergeRegistryAndVulkanGPUs(regGPUs []GPUInfo, vkProbes []VulkanDeviceProbe) []GPUInfo { used := make([]bool, len(vkProbes)) + probeRank := func(p VulkanDeviceProbe) (int, uint32, int) { + reqCount := 0 + for _, ext := range RequiredVulkanExtensions { + if p.Extensions[ext] { + reqCount++ + } + } + return reqCount, p.APIVersion, len(p.Extensions) + } + betterProbe := func(a, b VulkanDeviceProbe) bool { + ar, av, ae := probeRank(a) + br, bv, be := probeRank(b) + if ar != br { + return ar > br + } + if av != bv { + return av > bv + } + return ae > be + } matchProbe := func(g GPUInfo) *VulkanDeviceProbe { - // 1. Exact PCI vendor:device match. + // 1. Exact PCI vendor:device match, preferring the healthiest/newest ICD + // when stale manifests cause the same physical device to be enumerated + // multiple times. if g.VendorID != "" && g.DeviceID != "" { wantVen := strings.ToLower(g.VendorID) wantDev := strings.ToLower(g.DeviceID) + best := -1 for i := range vkProbes { if used[i] { continue } if fmt.Sprintf("%04x", vkProbes[i].VendorID) == wantVen && fmt.Sprintf("%04x", vkProbes[i].DeviceID) == wantDev { - used[i] = true - return &vkProbes[i] + if best < 0 || betterProbe(vkProbes[i], vkProbes[best]) { + best = i + } } } + if best >= 0 { + used[best] = true + return &vkProbes[best] + } } // 2. Case-insensitive name fallback only when PCI IDs are absent on either side; // never cross-match two different PCI devices that share a generic marketing name // (e.g. "AMD Radeon(TM) Graphics"). lowName := strings.ToLower(strings.TrimSpace(g.Name)) if lowName != "" { + best := -1 for i := range vkProbes { if used[i] { continue @@ -237,10 +266,15 @@ func MergeRegistryAndVulkanGPUs(regGPUs []GPUInfo, vkProbes []VulkanDeviceProbe) } pName := strings.ToLower(strings.TrimSpace(vkProbes[i].Name)) if pName == lowName || strings.Contains(pName, lowName) || strings.Contains(lowName, pName) { - used[i] = true - return &vkProbes[i] + if best < 0 || betterProbe(vkProbes[i], vkProbes[best]) { + best = i + } } } + if best >= 0 { + used[best] = true + return &vkProbes[best] + } } return nil } @@ -250,14 +284,59 @@ func MergeRegistryAndVulkanGPUs(regGPUs []GPUInfo, vkProbes []VulkanDeviceProbe) p := matchProbe(g) out = append(out, EvaluateGPUCompat(g, p)) } + + probeMatchesExisting := func(p VulkanDeviceProbe) bool { + pVen := "" + if p.VendorID != 0 { + pVen = fmt.Sprintf("%04x", p.VendorID) + } + pDev := "" + if p.DeviceID != 0 { + pDev = fmt.Sprintf("%04x", p.DeviceID) + } + pName := strings.ToLower(strings.TrimSpace(p.Name)) + for _, existing := range out { + eVen := strings.ToLower(strings.TrimSpace(existing.VendorID)) + eDev := strings.ToLower(strings.TrimSpace(existing.DeviceID)) + if pVen != "" && pDev != "" && eVen != "" && eDev != "" { + if pVen == eVen && pDev == eDev { + return true + } + continue + } + if pName != "" && strings.ToLower(strings.TrimSpace(existing.Name)) == pName { + return true + } + } + return false + } + // Include any non-CPU Vulkan GPU enumerated by vulkan-1.dll that wasn't // listed under the display-class registry (e.g. registered only under - // HKLM\SOFTWARE\Khronos\Vulkan\Drivers). + // HKLM\SOFTWARE\Khronos\Vulkan\Drivers), skipping duplicate ICD entries + // for a physical device already present in out. for i := range vkProbes { if used[i] || vkProbes[i].DeviceType == 4 { continue } p := vkProbes[i] + if probeMatchesExisting(p) { + continue + } + // If multiple Vulkan-only duplicates share this PCI ID, pick the best one. + if p.VendorID != 0 && p.DeviceID != 0 { + for j := i + 1; j < len(vkProbes); j++ { + if used[j] || vkProbes[j].DeviceType == 4 { + continue + } + if vkProbes[j].VendorID == p.VendorID && vkProbes[j].DeviceID == p.DeviceID { + used[j] = true + if betterProbe(vkProbes[j], p) { + p = vkProbes[j] + } + } + } + } base := GPUInfo{ Name: p.Name, Kind: ClassifyGPU(p.Name), diff --git a/internal/host/host_test.go b/internal/host/host_test.go index dc14969..046fbc5 100644 --- a/internal/host/host_test.go +++ b/internal/host/host_test.go @@ -165,6 +165,51 @@ func TestGPUCompatibilityGradingAndRecommendation(t *testing.T) { if noCross[3].DeviceID != "13c0" || noCross[3].Compat != GPUCompatSupported || noCross[3].VulkanICD != "" { t.Fatalf("13c0 probe should remain separate with no stale ICD: %+v", noCross[3]) } + + // 11. Duplicate Vulkan ICD enumerations for the same physical GPU are deduplicated, + // preferring the highest Vulkan version while preserving real multi-GPU setups. + v14 := uint32((1 << 22) | (4 << 12) | 303) + deduped := MergeRegistryAndVulkanGPUs( + []GPUInfo{ + {Name: "NVIDIA GeForce RTX 5070 Laptop GPU", VulkanICD: `C:\nv-vk64.json`, VendorID: "10de", DeviceID: "2d18", DriverVersion: "32.0.15.9174"}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VulkanICD: `C:\igvk64.json`, VendorID: "8086", DeviceID: "7d51", DriverVersion: "32.0.101.6554"}, + }, + []VulkanDeviceProbe{ + {Name: "NVIDIA GeForce RTX 5070 Laptop GPU", VendorID: 0x10de, DeviceID: 0x2d18, DeviceType: 2, APIVersion: v14, Extensions: allReqExts}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VendorID: 0x8086, DeviceID: 0x7d51, DeviceType: 1, APIVersion: v13, Extensions: allReqExts}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VendorID: 0x8086, DeviceID: 0x7d51, DeviceType: 1, APIVersion: v14, Extensions: allReqExts}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VendorID: 0x8086, DeviceID: 0x7d51, DeviceType: 1, APIVersion: v14, Extensions: allReqExts}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VendorID: 0x8086, DeviceID: 0x7d51, DeviceType: 1, APIVersion: v14, Extensions: allReqExts}, + {Name: "Intel(R) Arc(TM) 140T GPU (16GB)", VendorID: 0x8086, DeviceID: 0x7d51, DeviceType: 1, APIVersion: v14, Extensions: allReqExts}, + // Duplicate Vulkan-only GPU should also appear only once. + {Name: "AMD Radeon RX 7900 XTX", VendorID: 0x1002, DeviceID: 0x744c, DeviceType: 2, APIVersion: v13, Extensions: allReqExts}, + {Name: "AMD Radeon RX 7900 XTX", VendorID: 0x1002, DeviceID: 0x744c, DeviceType: 2, APIVersion: v14, Extensions: allReqExts}, + }, + ) + if len(deduped) != 3 { + t.Fatalf("expected 3 deduplicated GPUs, got %d: %+v", len(deduped), deduped) + } + if deduped[1].DriverVersion != "32.0.101.6554" || deduped[1].VulkanVersion != "1.4.303" { + t.Fatalf("expected Intel GPU to keep driver version and best Vulkan version, got %+v", deduped[1]) + } + if deduped[2].DeviceID != "744c" || deduped[2].VulkanVersion != "1.4.303" { + t.Fatalf("expected Vulkan-only duplicate to pick best version, got %+v", deduped[2]) + } + + // Real dual identical discrete GPUs (two distinct registry adapters) must both remain. + dualIdentical := MergeRegistryAndVulkanGPUs( + []GPUInfo{ + {Name: "NVIDIA GeForce RTX 4090", VulkanICD: `C:\nv-vk64.json`, VendorID: "10de", DeviceID: "2684", DriverVersion: "32.0.15.9174"}, + {Name: "NVIDIA GeForce RTX 4090", VulkanICD: `C:\nv-vk64.json`, VendorID: "10de", DeviceID: "2684", DriverVersion: "32.0.15.9174"}, + }, + []VulkanDeviceProbe{ + {Name: "NVIDIA GeForce RTX 4090", VendorID: 0x10de, DeviceID: 0x2684, DeviceType: 2, APIVersion: v14, Extensions: allReqExts}, + {Name: "NVIDIA GeForce RTX 4090", VendorID: 0x10de, DeviceID: 0x2684, DeviceType: 2, APIVersion: v14, Extensions: allReqExts}, + }, + ) + if len(dualIdentical) != 2 { + t.Fatalf("expected both physical identical GPUs to be kept, got %+v", dualIdentical) + } } func TestAffinityMaskHelpers(t *testing.T) { diff --git a/internal/macos/macosdriver/prepare.go b/internal/macos/macosdriver/prepare.go index fd4be3d..48ddfb2 100644 --- a/internal/macos/macosdriver/prepare.go +++ b/internal/macos/macosdriver/prepare.go @@ -293,10 +293,10 @@ func AppendNestedVirtIntent(in *plugin.StartIntent, locale i18n.Locale, vmDir, u } // prepareHostMemorySMBIOS appends `-smbios type=17,speed=...,memory_type=...` -// when SyncHostMemorySMBIOS is enabled in app config, overriding reims-ctl's -// hardcoded 2666 MHz DDR4 default with the host's probed RAM spec. -func (d *ReimsMacOSDriver) prepareHostMemorySMBIOS(cfg config.Config, rep host.Report, userExtraArgs string, supportsMemType func() bool, in *plugin.StartIntent) { - if !cfg.SyncHostMemorySMBIOS || rep.MemorySpec == nil || rep.MemorySpec.SpeedMHz <= 0 { +// by default whenever the host's RAM spec is available, overriding reims-ctl's +// hardcoded 2666 MHz DDR4 default unless the user supplies a manual type=17 arg. +func (d *ReimsMacOSDriver) prepareHostMemorySMBIOS(_ config.Config, rep host.Report, userExtraArgs string, supportsMemType func() bool, in *plugin.StartIntent) { + if rep.MemorySpec == nil || rep.MemorySpec.SpeedMHz <= 0 { in.ClearKeys = append(in.ClearKeys, keyHostMemorySMBIOS) return } diff --git a/internal/macos/macosdriver/prepare_smbios_test.go b/internal/macos/macosdriver/prepare_smbios_test.go index 9b5e79a..f883a5c 100644 --- a/internal/macos/macosdriver/prepare_smbios_test.go +++ b/internal/macos/macosdriver/prepare_smbios_test.go @@ -15,18 +15,11 @@ func TestPrepareHostMemorySMBIOS(t *testing.T) { MemorySpec: &host.HostMemorySpec{SpeedMHz: 6400, MemoryType: 34, TypeName: "DDR5"}, } - // Disabled by default: clears keyHostMemorySMBIOS. - var inOff plugin.StartIntent - drv.prepareHostMemorySMBIOS(config.Config{}, rep, "", func() bool { return true }, &inOff) - if len(inOff.Args) != 0 || !slices.Contains(inOff.ClearKeys, keyHostMemorySMBIOS) { - t.Fatalf("default off: got args=%v clear=%v", inOff.Args, inOff.ClearKeys) - } - - // Enabled with memory_type support: emits speed + memory_type. + // Enabled by default with memory_type support: emits speed + memory_type. var inOn plugin.StartIntent - drv.prepareHostMemorySMBIOS(config.Config{SyncHostMemorySMBIOS: true}, rep, "", func() bool { return true }, &inOn) + drv.prepareHostMemorySMBIOS(config.Config{}, rep, "", func() bool { return true }, &inOn) if len(inOn.Args) != 1 || !slices.Equal(inOn.Args[0].Tokens, []string{"-smbios", "type=17,speed=6400,memory_type=34"}) { - t.Fatalf("enabled with memory_type: got %+v", inOn.Args) + t.Fatalf("default with memory_type: got %+v", inOn.Args) } if err := plugin.ValidateArgFragment(inOn.Args[0]); err != nil { t.Fatalf("ValidateArgFragment rejected fragment: %v", err) @@ -34,21 +27,21 @@ func TestPrepareHostMemorySMBIOS(t *testing.T) { // Enabled without memory_type support: emits speed only. var inNoType plugin.StartIntent - drv.prepareHostMemorySMBIOS(config.Config{SyncHostMemorySMBIOS: true}, rep, "", func() bool { return false }, &inNoType) + drv.prepareHostMemorySMBIOS(config.Config{}, rep, "", func() bool { return false }, &inNoType) if len(inNoType.Args) != 1 || !slices.Equal(inNoType.Args[0].Tokens, []string{"-smbios", "type=17,speed=6400"}) { - t.Fatalf("enabled without memory_type: got %+v", inNoType.Args) + t.Fatalf("without memory_type: got %+v", inNoType.Args) } - // Enabled when host speed unavailable: clears key. + // Host speed unavailable: clears key. var inUnknown plugin.StartIntent - drv.prepareHostMemorySMBIOS(config.Config{SyncHostMemorySMBIOS: true}, host.Report{}, "", func() bool { return true }, &inUnknown) + drv.prepareHostMemorySMBIOS(config.Config{}, host.Report{}, "", func() bool { return true }, &inUnknown) if len(inUnknown.Args) != 0 || !slices.Contains(inUnknown.ClearKeys, keyHostMemorySMBIOS) { t.Fatalf("unknown speed: got args=%v clear=%v", inUnknown.Args, inUnknown.ClearKeys) } // User already supplied a manual -smbios type=17: respect it and clear ours. var inManual plugin.StartIntent - drv.prepareHostMemorySMBIOS(config.Config{SyncHostMemorySMBIOS: true}, rep, "-smbios type=17,speed=5200", func() bool { return true }, &inManual) + drv.prepareHostMemorySMBIOS(config.Config{}, rep, "-smbios type=17,speed=5200", func() bool { return true }, &inManual) if len(inManual.Args) != 0 || !slices.Contains(inManual.ClearKeys, keyHostMemorySMBIOS) { t.Fatalf("user manual type=17: got args=%v clear=%v", inManual.Args, inManual.ClearKeys) } diff --git a/internal/macos/startprep/startprep.go b/internal/macos/startprep/startprep.go index b46bac3..affa7cd 100644 --- a/internal/macos/startprep/startprep.go +++ b/internal/macos/startprep/startprep.go @@ -97,7 +97,7 @@ func (p *Prep) Prepare(ctx context.Context, name string, rep host.Report, cur *r } func (p *Prep) syncHostMemorySMBIOS(ctx context.Context, name string, rep host.Report, cur *reims.VMDetail) { - if !p.cfg.SyncHostMemorySMBIOS || rep.MemorySpec == nil || rep.MemorySpec.SpeedMHz <= 0 { + if rep.MemorySpec == nil || rep.MemorySpec.SpeedMHz <= 0 { return } if reims.HasSMBIOSType17Arg(cur.ExtraArgs) { diff --git a/internal/runtime/selection_test.go b/internal/runtime/selection_test.go index bce05a5..9f703e5 100644 --- a/internal/runtime/selection_test.go +++ b/internal/runtime/selection_test.go @@ -102,7 +102,7 @@ func TestSelectionRevalidatesAfterConsent(t *testing.T) { paths = append(paths, path) if len(paths) == 1 { prefs := cfg - prefs.SyncHostMemorySMBIOS = true + prefs.AutoPinPCores = false if err := SavePreferences(&prefs); err != nil { t.Fatal(err) } @@ -116,7 +116,7 @@ func TestSelectionRevalidatesAfterConsent(t *testing.T) { t.Fatalf("removed during consent: paths = %q, err = %v", paths, err) } saved, err := config.LoadExisting(filepath.Join(cfg.DataRoot, "reims-go.json")) - if err != nil || saved.ActiveRuntime != "old" || !saved.SyncHostMemorySMBIOS { + if err != nil || saved.ActiveRuntime != "old" || saved.AutoPinPCores { t.Fatalf("lost settings while awaiting consent: %+v, %v", saved, err) } } diff --git a/locales/en-US/settings.json b/locales/en-US/settings.json index 101fc43..bdabe48 100644 --- a/locales/en-US/settings.json +++ b/locales/en-US/settings.json @@ -439,9 +439,6 @@ "smbiosCheckHint": "Tip: check the serial at checkcoverage.apple.com and verify it reports invalid (not registered to a real Mac) before writing.", "smbiosStopRequired": "Shut down the VM completely first (not running or suspended)", "smbiosLoadFailed": "Could not read OpenCore SMBIOS", - "syncHostMemorySMBIOS": "Sync host memory specs", - "syncHostMemorySMBIOSSub": "Show the host's actual memory speed and generation ({spec}) in macOS About This Mac; applies on next start", - "syncHostMemorySMBIOSUnavailable": "Could not read host SMBIOS memory speed; VMs keep the default 2666 MHz DDR4", "targetDisplayTitle": "Launch display", "targetDisplayPrimaryDefault": "Primary display (default)", "targetDisplayNumbered": "Display {n}", diff --git a/locales/zh-CN/settings.json b/locales/zh-CN/settings.json index 9d84d41..d616199 100644 --- a/locales/zh-CN/settings.json +++ b/locales/zh-CN/settings.json @@ -439,9 +439,6 @@ "smbiosCheckHint": "建议将序列号复制到 checkcoverage.apple.com 确认显示「无效序列号」(未被真机占用)后再写入。", "smbiosStopRequired": "请先彻底关机(不能处于运行或休眠状态)", "smbiosLoadFailed": "无法读取 OpenCore 设备码", - "syncHostMemorySMBIOS": "同步宿主机内存规格", - "syncHostMemorySMBIOSSub": "在 macOS「关于本机」中显示宿主机真实内存频率与代数(当前:{spec}),下次启动生效", - "syncHostMemorySMBIOSUnavailable": "未能从宿主机 SMBIOS 读取物理内存频率,虚拟机将保持默认的 2666 MHz DDR4", "targetDisplayTitle": "启动显示器", "targetDisplayPrimaryDefault": "主显示器(默认)", "targetDisplayNumbered": "显示器 {n}",