jp7677 / dxvk-nvapi

Alternative NVAPI implementation on top of DXVK.
MIT License
353 stars 32 forks source link

nvapi doesn't work on Wine 9.x Wayland sessions.. #165

Closed oscarbg closed 4 months ago

oscarbg commented 4 months ago

similar issue to https://github.com/jp7677/dxvk-nvapi/issues/150 but even with no winewayland.drv.. in fact the findings in https://github.com/jp7677/dxvk-nvapi/issues/150 are correct but the problem is due to Wayland session and not just related to winewayland.drv.. can test on KDE Plasma Wayland or GNOME Wayland and results are equally bad..

using wine 9.3 master and DXVK-nvapi with reflex:v0.6.4-57-gb54c9fe seeing logs of vk_streamline app on X11 vs Wayland.. this breaks use of DLSS for example.. using Wine master and specifically I see new errors in Wayland in DXVK logs:

warn:  DXGI: Found monitors not associated with any adapter, using fallback
info:  Adapter LUID 0: 0:3f6
err:   readMonitorEdidFromKey: Failed to get EDID reg key size
err:   DXGI: Failed to parse display metadata + colorimetry info, using blank.

not present in X11..

which lead to streamline logs in Wayland:

[07.03.2024 03-51-03][streamline][info]commoninterface.cpp:261[getSystemCaps] NVIDIA driver 550.40
[07.03.2024 03-51-03][streamline][error]commoninterface.cpp:271[getSystemCaps] NvAPI_GPU_GetLogicalGpuInfo(hLogicalGPU, &lData) failed error -1

vs on X11:

[07.03.2024 03-48-31][streamline][info]commoninterface.cpp:261[getSystemCaps] NVIDIA driver 550.40
[07.03.2024 03-48-31][streamline][info]commoninterface.cpp:286[getSystemCaps] Adapter 0 architecture 0x190 implementation 0x2 revision 0xffffffff - bit 0x1 - LUID 0.1010

seems the error why NvAPI_GPU_GetLogicalGpuInfo fails in wayland is due to bad LUID as seen in nvapi64-tests: https://github.com/jp7677/dxvk-nvapi/blob/b54c9fe968fe2dc8eb237bfbd9de6f4cf58bc9d8/src/nvapi_gpu.cpp#L358

full nvapi64-tests show diff is error is related to LUID retrieval not working in DXVK(?) or DXVK-NVAPI(?=): wayland:

Adapter ID/LUID:            N/A

X11: Adapter ID/LUID: f2030000-00000000 (0x00000000/0x000003f2) full logs: wayland:

wine64 nvapi64-tests.exe 
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
Randomness seeded to: 487401473
info:  Game: nvapi64-tests.exe
info:  DXVK: v2.3-26-g5e06cf95737ccf80
info:  Vulkan: Found vkGetInstanceProcAddr in winevulkan.dll @ 0x6ffffc433fd0
info:  Built-in extension providers:
info:    Win32 WSI
info:    OpenVR
info:    OpenXR
info:  OpenVR: could not open registry key, status 2
info:  OpenVR: Failed to locate module
info:  Enabled instance extensions:
info:    VK_EXT_surface_maintenance1
info:    VK_KHR_get_surface_capabilities2
info:    VK_KHR_surface
info:    VK_KHR_win32_surface
info:  NVIDIA GeForce RTX 4070:
info:    Driver : NVIDIA 550.40.53
info:    Memory Heap[0]: 
info:      Size: 12282 MiB
info:      Flags: 0x1
info:      Memory Type[1]: Property Flags = 0x1
info:      Memory Type[4]: Property Flags = 0x7
info:    Memory Heap[1]: 
info:      Size: 72204 MiB
info:      Flags: 0x0
info:      Memory Type[0]: Property Flags = 0x0
info:      Memory Type[2]: Property Flags = 0x6
info:      Memory Type[3]: Property Flags = 0xe
warn:  DXGI: Found monitors not associated with any adapter, using fallback
info:  Adapter LUID 0: 0:3f5
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fa96c, paths 0x7ffffeb2c4d0, modes_count 0x7ffffe2fa9d0, modes 0x7ffffeaff8c0, topology_id (nil) semi-stub
err:   readMonitorEdidFromKey: Failed to get EDID reg key size
err:   DXGI: Failed to parse display metadata + colorimetry info, using blank.
--------------------------------
Interface version:              NVAPI Open Source Interface (DXVK-NVAPI)
Driver version:                 550.40
Driver branch:                  r550_v0.6.4-57-gb54c9fe
Driver base branch:             r550
    ----------------------------
    GPU 0
    GPU name:                   NVIDIA GeForce RTX 4070
    GPU type:                   2 (Discrete)
    Device ID:                  0x278610de
    Subsystem ID:               N/A
    Bus:Slot ID:                PCI:01:00
    Board ID:                   0x100
    Physical framebuffer size:  12282MB
    Adapter ID/LUID:            N/A
    Architecture ID:            0x00000190 (Ada)
    Implementation ID:          0x00000002
    GPU core count:             N/A
    Current PCIe link width:    N/A
    IRQ:                        N/A
    Compute capable:            Yes (Compute GPU topology flags: 0x0b)
    VBIOS version:              N/A
    Current GPU utilization:    N/A
    Current memory utilization: N/A
    Current video utilization:  N/A
    Current GPU temperature:    N/A
    Current performance state:  N/A
    Current graphics clock:     N/A
    Current memory clock:       N/A
    Current video clock:        N/A
    Connected display ID(s):    0x00010001

    ----------------------------
    Display 0
    Display name:               \\.\DISPLAY1 (Primary)
    Display ID:                 0x00010001
    Connected to:               GPU 0
    ST2084/HDR support:         -
    Primary 0/red:              X = 32000, Y = 16500
    Primary 1/green:            X = 15000, Y = 30000
    Primary 2/blue:             X = 7500, Y = 3000
    White point:                X = 15635, Y = 16450
    Desired luminance:          Min = 0.5, Max = 270, Max frame avg = 270

===============================================================================
All tests passed (82 assertions in 1 test case)

x11:

wine64 nvapi64-tests.exe 
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
0098:fixme:wineusb:query_id Unhandled ID query type 0x5.
Randomness seeded to: 3760266711
info:  Game: nvapi64-tests.exe
info:  DXVK: v2.3-26-g5e06cf95737ccf80
info:  Vulkan: Found vkGetInstanceProcAddr in winevulkan.dll @ 0x6ffffa083fd0
info:  Built-in extension providers:
info:    Win32 WSI
info:    OpenVR
info:    OpenXR
info:  OpenVR: could not open registry key, status 2
info:  OpenVR: Failed to locate module
info:  Enabled instance extensions:
info:    VK_EXT_surface_maintenance1
info:    VK_KHR_get_surface_capabilities2
info:    VK_KHR_surface
info:    VK_KHR_win32_surface
info:  NVIDIA GeForce RTX 4070:
info:    Driver : NVIDIA 550.40.53
info:    Memory Heap[0]: 
info:      Size: 12282 MiB
info:      Flags: 0x1
info:      Memory Type[1]: Property Flags = 0x1
info:      Memory Type[4]: Property Flags = 0x7
info:    Memory Heap[1]: 
info:      Size: 72204 MiB
info:      Flags: 0x0
info:      Memory Type[0]: Property Flags = 0x0
info:      Memory Type[2]: Property Flags = 0x6
info:      Memory Type[3]: Property Flags = 0xe
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fe2f8, paths 0x7ffffeb285c0, modes_count 0x7ffffe2fe2fc, modes 0x7ffffeaff910, topology_id (nil) semi-stub
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fe2f8, paths 0x7ffffeb285c0, modes_count 0x7ffffe2fe2fc, modes 0x7ffffeaff910, topology_id (nil) semi-stub
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fdb98, paths 0x7ffffeb2c520, modes_count 0x7ffffe2fdb9c, modes 0x7ffffeaff910, topology_id (nil) semi-stub
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fa96c, paths 0x7ffffeb2c520, modes_count 0x7ffffe2fa9d0, modes 0x7ffffeaff910, topology_id (nil) semi-stub
0024:fixme:system:NtUserQueryDisplayConfig flags 0x2, paths_count 0x7ffffe2fdb98, paths 0x7ffffeb2c520, modes_count 0x7ffffe2fdb9c, modes 0x7ffffeaff910, topology_id (nil) semi-stub
--------------------------------
Interface version:              NVAPI Open Source Interface (DXVK-NVAPI)
Driver version:                 550.40
Driver branch:                  r550_v0.6.4-57-gb54c9fe
Driver base branch:             r550
    ----------------------------
    GPU 0
    GPU name:                   NVIDIA GeForce RTX 4070
    GPU type:                   2 (Discrete)
    Device ID:                  0x278610de
    Subsystem ID:               N/A
    Bus:Slot ID:                PCI:01:00
    Board ID:                   0x100
    Physical framebuffer size:  12282MB
    Adapter ID/LUID:            f2030000-00000000 (0x00000000/0x000003f2)
    Architecture ID:            0x00000190 (Ada)
    Implementation ID:          0x00000002
    GPU core count:             N/A
    Current PCIe link width:    N/A
    IRQ:                        N/A
    Compute capable:            Yes (Compute GPU topology flags: 0x0b)
    VBIOS version:              N/A
    Current GPU utilization:    N/A
    Current memory utilization: N/A
    Current video utilization:  N/A
    Current GPU temperature:    N/A
    Current performance state:  N/A
    Current graphics clock:     N/A
    Current memory clock:       N/A
    Current video clock:        N/A
    Connected display ID(s):    0x00010001

    ----------------------------
    Display 0
    Display name:               \\.\DISPLAY1 (Primary)
    Display ID:                 0x00010001
    Connected to:               GPU 0
    ST2084/HDR support:         -
    Primary 0/red:              X = 33642, Y = 15673
    Primary 1/green:            X = 13818, Y = 32617
    Primary 2/blue:             X = 7617, Y = 2392
    White point:                X = 15625, Y = 16406
    Desired luminance:          Min = 0.5, Max = 270, Max frame avg = 270

===============================================================================
All tests passed (82 assertions in 1 test case)
Saancreed commented 4 months ago

Upstream Wine relies on xrandr providers to assign LUIDs to GPUs. Obviously, xrandr doesn't expose any providers on xwayland so on upstream Wine you'll see no LUIDs when using Wayland session.

On the other hand, Proton has some winex11 hacks in place to ensure that even GPUs with no xrandr providers will be added and get some LUID assigned. Feel free to re-run tests with Proton's Wine, you should see some better results even on Wayland session there.

And Wayland driver failing to add GPUs / assign LUIDs sounds like a winewayland bug (or perhaps just incomplete feature) to me.

oscarbg commented 4 months ago

@Saancreed many thanks for pointing the "winex11 hacks" patch!! I built wine master with this patch (+ hags) and now it works on Wayland.. (using winex11.drv) as you say seems winewayland.drv is not ready.. and fails equally.. hope somebody post an equivalent winewayland.drv patch as the winex11 patch relies only on Vulkan (not xrandr)..