The host page's optimizations list gains a "Windows processor scheduling" row: it shows whether Windows favours programs or background services (Win32PrioritySeparation, read without elevation) and a button that opens System Properties' Performance Options through one UAC prompt, so the choice saves without a second one. Declining the prompt is not an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
123 lines
4.8 KiB
Go
123 lines
4.8 KiB
Go
package host
|
|
|
|
import "strings"
|
|
|
|
type GPUKind string
|
|
|
|
const (
|
|
GPUDiscrete GPUKind = "discrete"
|
|
GPUIntegrated GPUKind = "integrated"
|
|
GPUVirtual GPUKind = "virtual"
|
|
GPUUnknown GPUKind = "unknown"
|
|
)
|
|
|
|
type GPUInfo struct {
|
|
Name string `json:"name"`
|
|
VulkanICD string `json:"vulkan_icd"`
|
|
Kind GPUKind `json:"kind"`
|
|
}
|
|
|
|
type WHPXState string
|
|
|
|
const (
|
|
WHPXReady WHPXState = "ready"
|
|
WHPXNoHypervisor WHPXState = "no_hypervisor"
|
|
WHPXMissing WHPXState = "missing"
|
|
WHPXUnsupported WHPXState = "unsupported"
|
|
)
|
|
|
|
type WHPXCapabilities struct {
|
|
ModernOS bool `json:"modern_os"`
|
|
APICEmulation bool `json:"apic_emulation"`
|
|
KernelIrqchipAvailable bool `json:"kernel_irqchip_available"`
|
|
NestedVirtProperty bool `json:"nested_virt_property"`
|
|
NestedVirtProbeError string `json:"nested_virt_probe_error,omitempty"`
|
|
}
|
|
|
|
type Report struct {
|
|
OS string `json:"os"`
|
|
Arch string `json:"arch"`
|
|
LogicalCPUs int `json:"logical_cpus"`
|
|
PhysicalCores int `json:"physical_cores"`
|
|
HasHybridCores bool `json:"has_hybrid_cores"`
|
|
PCoreCount int `json:"p_core_count"`
|
|
ECoreCount int `json:"e_core_count"`
|
|
LPECoreCount int `json:"lpe_core_count,omitempty"`
|
|
PCoreMask uint64 `json:"p_core_mask"`
|
|
PCoreMaskHex string `json:"p_core_mask_hex"`
|
|
PCoreLogicalCPUs []int `json:"p_core_logical_cpus,omitempty"`
|
|
ECoreLogicalCPUs []int `json:"e_core_logical_cpus,omitempty"`
|
|
NonLPEMask uint64 `json:"non_lpe_mask,omitempty"`
|
|
NonLPEMaskHex string `json:"non_lpe_mask_hex,omitempty"`
|
|
NonLPELogicalCPUs []int `json:"non_lpe_logical_cpus,omitempty"`
|
|
TotalRAMGB float64 `json:"total_ram_gb"`
|
|
AvailRAMGB float64 `json:"avail_ram_gb"`
|
|
MemoryLoadPct int `json:"memory_load_pct"`
|
|
// Commit memory: QEMU commits all guest RAM at start (CreateFileMapping), so
|
|
// a VM needs its memory free in the commit charge, not just in physical RAM.
|
|
// Measured 2026-11-28: 14.7 GiB commit free with 17.3 GiB physical free, and a
|
|
// 16G guest failed ("Cannot set up guest memory"). portable-runtime-spec.md §5.1.
|
|
CommitAvailGB float64 `json:"commit_avail_gb"`
|
|
CommitLimitGB float64 `json:"commit_limit_gb"`
|
|
DataRoot string `json:"data_root"`
|
|
DataRootDriveType string `json:"data_root_drive_type,omitempty"`
|
|
FreeDiskGB float64 `json:"free_disk_gb"`
|
|
WHPX WHPXState `json:"whpx"`
|
|
WHPXCaps WHPXCapabilities `json:"whpx_caps"`
|
|
NeedsColdRebootWorkaround bool `json:"needs_cold_reboot_workaround"`
|
|
GPUs []GPUInfo `json:"gpus"`
|
|
RecommendedGPU *GPUInfo `json:"recommended_gpu,omitempty"`
|
|
Displays []DisplayInfo `json:"displays,omitempty"`
|
|
PrimaryDisplay *DisplayInfo `json:"primary_display,omitempty"`
|
|
RecommendedResolution string `json:"recommended_resolution,omitempty"`
|
|
DisplayPresets []DisplayPreset `json:"display_presets,omitempty"`
|
|
HiDPIAdvice string `json:"hidpi_advice,omitempty"` // how to reach HiDPI when no preset does (display.go)
|
|
FullscreenHiDPI bool `json:"fullscreen_hidpi"` // a borderless window on the primary screen is HiDPI
|
|
ProcessorScheduling string `json:"processor_scheduling,omitempty"` // "programs" or "background" (scheduling.go)
|
|
Audio AudioInfo `json:"audio"`
|
|
}
|
|
|
|
// ClassifyGPU distinguishes discrete, integrated, and virtual display adapters.
|
|
func ClassifyGPU(name string) GPUKind {
|
|
low := strings.ToLower(name)
|
|
for _, v := range []string{"todesk", "gameviewer", "parsec", "virtual", "idd", "microsoft basic", "spacedesk"} {
|
|
if strings.Contains(low, v) {
|
|
return GPUVirtual
|
|
}
|
|
}
|
|
for _, d := range []string{"nvidia", "geforce", "rtx", "gtx", "quadro", "radeon rx", "radeon pro", "intel(r) arc"} {
|
|
if strings.Contains(low, d) {
|
|
return GPUDiscrete
|
|
}
|
|
}
|
|
for _, i := range []string{"intel(r) uhd", "intel(r) hd", "intel(r) iris", "radeon(tm) graphics"} {
|
|
if strings.Contains(low, i) {
|
|
return GPUIntegrated
|
|
}
|
|
}
|
|
return GPUUnknown
|
|
}
|
|
|
|
// PickRecommendedGPU selects the best Vulkan GPU (preferring discrete over integrated, skipping virtual).
|
|
func PickRecommendedGPU(gpus []GPUInfo) *GPUInfo {
|
|
for i := range gpus {
|
|
if gpus[i].Kind == GPUDiscrete && gpus[i].VulkanICD != "" {
|
|
cp := gpus[i]
|
|
return &cp
|
|
}
|
|
}
|
|
for i := range gpus {
|
|
if gpus[i].Kind == GPUIntegrated && gpus[i].VulkanICD != "" {
|
|
cp := gpus[i]
|
|
return &cp
|
|
}
|
|
}
|
|
for i := range gpus {
|
|
if gpus[i].Kind != GPUVirtual && gpus[i].VulkanICD != "" {
|
|
cp := gpus[i]
|
|
return &cp
|
|
}
|
|
}
|
|
return nil
|
|
}
|