patrick-theprogrammer / WindowsDisplayManager

A powershell module for managing Windows display settings.
https://www.powershellgallery.com/packages/WindowsDisplayManager
MIT License
15 stars 1 forks source link

Incorrect data with two GPUs #1

Open journeym opened 3 months ago

journeym commented 3 months ago

I have one monitor connected to PCIE Nvidia card, and another to iGPU. This module gives me incorrect data with GetEnabledDisplays (shows only monitor connected to the igpu but with incorrect connection data) image GetAllPotentialDisplays gives me this. image MSI MD271CPW is actually connected to radeon igpu, and on nvidia i have LG Ultragear.

Cynary commented 2 months ago

I have a similar issue that may have the same underlying cause, but should be easier to reproduce since it doesn't require a second CPU.

I'm trying to script the setup/teardown of a virtual display (this is for some streaming-related automation), and for the virtual display I'm using https://github.com/itsmikethetech/Virtual-Display-Driver.

When I don't have the virtual device, I just have a single graphics card, and everything looks and works well:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0-4353       AW3423DWF via NVIDIA   True    True     False    Width       : 3440   HdrSupported : True    X : -3440  Width  : 3440            Id          : 0              Id             : 4353
             GeForce RTX 4090                                 Height      : 1440   HdrEnabled   : True    Y : 0      Height : 1440            Name        : \\.\DISPLAY1   FriendlyName   : AW3423DWF
                                                              RefreshRate : 165    BitDepth     : 10                                          Description : NVIDIA         ConnectionType :
                                                                                                                                              GeForce RTX 4090             DisplayportExternal
1-4352       DENON-AVR via NVIDIA   True    True     True     Width       : 3840   HdrSupported : True    X : 0      Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 120    BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090

(for the following examples, I will always keep the DENON-AVR display enabled) When I add it as a device, the output from GetAllPotentialDisplays gets wonky, and controls weird - also, what we see in that output depends on which displays are enabled via settings. Here's the output when both the alienware and the virtual display are enabled, and the virtual display is the primary:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0-256        IDD HDR via NVIDIA     True    True     False    Width       : 3440   HdrSupported : True    X : -3440  Width  : 1280            Id          : 0              Id             : 256
             GeForce RTX 4090                                 Height      : 1440   HdrEnabled   : False   Y : 0      Height : 800             Name        : \\.\DISPLAY1   FriendlyName   : IDD HDR
                                                              RefreshRate : 60     BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
1-4352       DENON-AVR via NVIDIA   True    True     False    Width       : 3840   HdrSupported : True    X : 1280   Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 60     BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
4            Unconnected            True    False    True     Width       : 1280   N/A                    X : 0      N/A                      Id          : 4              None
             IddSampleDriver                                  Height      : 800                           Y : 0                               Name        : \\.\DISPLAY15
             Device HDR source                                RefreshRate : 60                                                                Description :
                                                                                                                                              IddSampleDriver Device HDR

Here's the output when both are enabled, and the alienware is the primary:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0-256        IDD HDR via NVIDIA     True    True     True     Width       : 3440   HdrSupported : True    X : 0      Width  : 1280            Id          : 0              Id             : 256
             GeForce RTX 4090                                 Height      : 1440   HdrEnabled   : False   Y : 0      Height : 800             Name        : \\.\DISPLAY1   FriendlyName   : IDD HDR
                                                              RefreshRate : 60     BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
1-4352       DENON-AVR via NVIDIA   True    True     False    Width       : 3840   HdrSupported : True    X : 4720   Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 60     BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
4            Unconnected            True    False    False    Width       : 1280   N/A                    X : 3440   N/A                      Id          : 4              None
             IddSampleDriver                                  Height      : 800                           Y : 0                               Name        : \\.\DISPLAY15
             Device HDR source                                RefreshRate : 60                                                                Description :
                                                                                                                                              IddSampleDriver Device HDR

Here's the output when only the alienware is enabled:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0-4353       AW3423DWF via NVIDIA   True    True     False    Width       : 3440   HdrSupported : True    X : -3440  Width  : 3440            Id          : 0              Id             : 4353
             GeForce RTX 4090                                 Height      : 1440   HdrEnabled   : True    Y : 0      Height : 1440            Name        : \\.\DISPLAY1   FriendlyName   : AW3423DWF
                                                              RefreshRate : 165    BitDepth     : 10                                          Description : NVIDIA         ConnectionType :
                                                                                                                                              GeForce RTX 4090             DisplayportExternal
1-4352       DENON-AVR via NVIDIA   True    True     True     Width       : 3840   HdrSupported : True    X : 0      Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 120    BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
4            Unconnected            False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 4              None
             IddSampleDriver                                                                                                                  Name        : \\.\DISPLAY15
             Device HDR source                                                                                                                Description :
                                                                                                                                              IddSampleDriver Device HDR

Here's the output when neither is enabled:

Display ID   Description            Active  Enabled  Primary  Resolution           HDR Info               Position   Recommended Resolution   Source                       Target
----------   -----------            ------  -------  -------  ----------           --------               --------   ----------------------   ------                       ------
0            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 0              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY1
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
1-4352       DENON-AVR via NVIDIA   True    True     True     Width       : 3840   HdrSupported : True    X : 0      Width  : 3840            Id          : 1              Id             : 4352
             GeForce RTX 4090                                 Height      : 2160   HdrEnabled   : True    Y : 0      Height : 2160            Name        : \\.\DISPLAY2   FriendlyName   : DENON-AVR
                                                              RefreshRate : 120    BitDepth     : 10                                          Description : NVIDIA         ConnectionType : Hdmi
                                                                                                                                              GeForce RTX 4090
2            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 2              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY3
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
3            Unconnected NVIDIA     False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 3              None
             GeForce RTX 4090                                                                                                                 Name        : \\.\DISPLAY4
             source                                                                                                                           Description : NVIDIA
                                                                                                                                              GeForce RTX 4090
4            Unconnected            False   False    False    N/A                  N/A                    N/A        N/A                      Id          : 4              None
             IddSampleDriver                                                                                                                  Name        : \\.\DISPLAY15
             Device HDR source                                                                                                                Description :
                                                                                                                                              IddSampleDriver Device HDR

It kind of looks/feels like the 0-indexed display becomes a mix of two displays, though the virtual monitor is also on the index-4 - enabling/disabling/enabling HDR/disabling HDR work on display 0 if I grab the output of GetAllPotentialDisplays when only one of the displays is active. If both displays are active, enable/disable seems to act on both displays (in that it lets me disable the alienware monitor, though it doesn't let me reenable it). Setting the resolution, however, is a different story - setting the resolution of display 0 only affects the alienware monitor, whereas I can set the resolution for the virtual monitor on display 4.

I tried to look a little deeper into this, and when I tried to get the list of paths for index 0 (following the code in _GetDisplay), this is what I got:

[
    {
        "sourceInfo":  {
                           "adapterId":  "DisplayConfig+LUID",
                           "id":  1,
                           "modeInfoIdx":  1,
                           "statusFlags":  1
                       },
        "targetInfo":  {
                           "adapterId":  "DisplayConfig+LUID",
                           "id":  4352,
                           "modeInfoIdx":  0,
                           "outputTechnology":  5,
                           "rotation":  1,
                           "scaling":  1,
                           "refreshRate":  "DisplayConfig+DisplayConfigRational",
                           "scanLineOrdering":  1,
                           "targetAvailable":  true,
                           "statusFlags":  1
                       },
        "flags":  1
    },
    {
        "sourceInfo":  {
                           "adapterId":  "DisplayConfig+LUID",
                           "id":  0,
                           "modeInfoIdx":  3,
                           "statusFlags":  1
                       },
        "targetInfo":  {
                           "adapterId":  "DisplayConfig+LUID",
                           "id":  256,
                           "modeInfoIdx":  2,
                           "outputTechnology":  5,
                           "rotation":  1,
                           "scaling":  1,
                           "refreshRate":  "DisplayConfig+DisplayConfigRational",
                           "scanLineOrdering":  1,
                           "targetAvailable":  true,
                           "statusFlags":  1
                       },
        "flags":  1
    }
]

This looks very similar to the issue reported with 2 gpus - the module output seems to suggests both gpus have a monitor at index 0, so the module ends up mixing them up in weird ways. Hopefully using virtual monitor this is easier to reproduce, and can lead to a fix.

journeym commented 3 weeks ago

After latest windows / nvidia driver update it changed behaivior. Now its showing primary monitor correctly, but wont show second one as connected, though it's working fine. image