|
1 | 1 | . "$PSScriptRoot\..\..\scripts\Common.ps1" |
2 | 2 |
|
| 3 | +# {4d36e968-e325-11ce-bfc1-08002be10318} = Display Adapters device class GUID |
| 4 | +$DISPLAY_ADAPTER_CLASS = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}" |
| 5 | + |
| 6 | +function Get-DisplayAdapterIndices { |
| 7 | + # Dynamically enumerate all display adapter registry indices instead of hardcoding 0000-0003 |
| 8 | + if (-not (Test-Path $DISPLAY_ADAPTER_CLASS)) { return @() } |
| 9 | + Get-ChildItem -Path $DISPLAY_ADAPTER_CLASS -ErrorAction SilentlyContinue | |
| 10 | + Where-Object { $_.PSChildName -match '^\d{4}$' } | |
| 11 | + ForEach-Object { $_.PSChildName } |
| 12 | +} |
| 13 | + |
3 | 14 | function Show-GPUMenu { |
4 | 15 | Invoke-MenuLoop -Title "GPU-Specific Tweaks" -Items @( |
5 | 16 | "[1] NVIDIA", |
@@ -39,17 +50,13 @@ function Invoke-NvidiaTweaks { |
39 | 50 | ) |
40 | 51 |
|
41 | 52 | # source - https://github.com/AlchemyTweaks/Verified-Tweaks/blob/main/Nvidia/RmGpsPsEnablePerCpuCoreDpc |
42 | | - # Detect NVIDIA GPU presence |
43 | 53 | $nvidiaFound = $false |
44 | | - $classPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}" |
45 | | - foreach ($idx in @("0000", "0001", "0002", "0003")) { |
46 | | - $devPath = "$classPath\$idx" |
47 | | - if (Test-Path $devPath) { |
48 | | - $provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName |
49 | | - if ($provider -match "NVIDIA") { |
50 | | - $nvidiaFound = $true |
51 | | - break |
52 | | - } |
| 54 | + foreach ($idx in (Get-DisplayAdapterIndices)) { |
| 55 | + $devPath = "$DISPLAY_ADAPTER_CLASS\$idx" |
| 56 | + $provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName |
| 57 | + if ($provider -match "NVIDIA") { |
| 58 | + $nvidiaFound = $true |
| 59 | + break |
53 | 60 | } |
54 | 61 | } |
55 | 62 | if (-not $nvidiaFound) { |
@@ -81,18 +88,13 @@ function Invoke-AMDTweaks { |
81 | 88 | ) |
82 | 89 |
|
83 | 90 | # source - https://youtu.be/nuUV2RoPOWc , https://github.com/AlchemyTweaks/Verified-Tweaks/blob/main/AMD%20Radeon/AMD%20Tweak%20Melody |
84 | | - # {4d36e968-e325-11ce-bfc1-08002be10318} = Display Adapters device class GUID |
85 | | - # Detect AMD GPU device index dynamically instead of assuming \0000 |
86 | | - $classPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}" |
87 | 91 | $amdPath = $null |
88 | | - foreach ($idx in @("0000", "0001", "0002", "0003")) { |
89 | | - $devPath = "$classPath\$idx" |
90 | | - if (Test-Path $devPath) { |
91 | | - $provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName |
92 | | - if ($provider -match "AMD|ATI|Advanced Micro Devices") { |
93 | | - $amdPath = $devPath |
94 | | - break |
95 | | - } |
| 92 | + foreach ($idx in (Get-DisplayAdapterIndices)) { |
| 93 | + $devPath = "$DISPLAY_ADAPTER_CLASS\$idx" |
| 94 | + $provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName |
| 95 | + if ($provider -match "AMD|ATI|Advanced Micro Devices") { |
| 96 | + $amdPath = $devPath |
| 97 | + break |
96 | 98 | } |
97 | 99 | } |
98 | 100 | if (-not $amdPath) { |
|
0 commit comments