bottlesdevs / Bottles

Run Windows software and games on Linux
https://usebottles.com
GNU General Public License v3.0
6.34k stars 265 forks source link

[Bug]: gamescope with NVidia Optimus fails to display anything on the host #2733

Open mrsteyk opened 1 year ago

mrsteyk commented 1 year ago

Describe the bug

When using gamescope feature with discrete gpu option enabled (Intel+NVidia configuration) under Wayland, gamescope reliably fails to make a window on the host to display anything.

To Reproduce

  1. Go to bottle's settings
  2. Make sure discrete gpu and gamescope are enabled
  3. Run any application

Package

Flatpak from Flathub

Distribution

Arch Linux

Debugging Information

Official Package: true
Version: '51.5'
DE/WM: null
Display:
    X.org: true
    X.org (port): :0
    Wayland: true
Graphics:
    vendors:
        nvidia: &id002
            vendor: nvidia
            envs:
                __NV_PRIME_RENDER_OFFLOAD: '1'
                __GLX_VENDOR_LIBRARY_NAME: nvidia
                __VK_LAYER_NV_optimus: NVIDIA_only
            icd: /usr/lib/x86_64-linux-gnu/GL/vulkan/icd.d/nvidia_icd.json:/usr/lib/i386-linux-gnu/GL/vulkan/icd.d/nvidia_icd.json
            nvngx_path: /usr/lib/x86_64-linux-gnu/GL/nvidia-525-89-02/extra/nvidia/wine
        intel: &id001
            vendor: intel
            envs:
                DRI_PRIME: '1'
            icd: /usr/lib/x86_64-linux-gnu/GL/vulkan/icd.d/intel_icd.x86_64.json:/usr/lib/x86_64-linux-gnu/GL/vulkan/icd.d/intel_hasvk_icd.x86_64.json:/usr/lib/i386-linux-gnu/GL/vulkan/icd.d/intel_icd.i686.json:/usr/lib/i386-linux-gnu/GL/vulkan/icd.d/intel_hasvk_icd.i686.json
    prime:
        integrated: *id001
        discrete: *id002
Kernel:
    Type: Linux
    Version: 6.1.12-arch1-1
Disk:
    Total: 8286691328
    Free: 8286523392
RAM:
    MemTotal: 15.4GiB
    MemAvailable: 11.0GiB
Bottles_envs: null

Troubleshooting Logs

No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
wlserver: [backend/headless/backend.c:68] Creating headless backend
vulkan: selecting physical device 'NVIDIA GeForce GTX 1050 Ti': queue family 2
vulkan: physical device supports DRM format modifiers
vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x3231564E (VkResult: 0)
vulkan: supported DRM formats for sampling usage:
vulkan:   0x34325241
vulkan:   0x34325258
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:16] Starting headless backend
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X1: Address already in use
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X2: Address already in use
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X3: Address already in use
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X4: Address already in use
wlserver: [xwayland/server.c:108] Starting Xwayland on :5
wlserver: [types/wlr_compositor.c:681] New wlr_surface 0x5622d83c1550 (res 0x5622d83c7130)
wlserver: [xwayland/server.c:273] Xserver is ready
pipewire: stream state changed: connecting
pipewire: stream state changed: paused
pipewire: stream available on node ID: 82
wineserver: using server-side synchronization.
wine: RLIMIT_NICE is <= 20, unable to use setpriority safely
002c:err:wineboot:process_run_key Error running cmd L"C:\\windows\\system32\\winemenubuilder.exe -r" (2).
00d4:err:xrandr:xrandr14_get_adapters Failed to get adapters
Setting breakpad minidump AppID = 1449200
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  76561194789371904 [API loaded no]
wlserver: [types/wlr_compositor.c:681] New wlr_surface 0x5622d8448290 (res 0x5622d83cd580)
Error getting buffer

Additional context

This was tested under sway, labwc and weston. Using prime-run to launch compositors didn't help. Log attached is from running a game launcher, when running game itself same "no gamescope window" thing happens, but you can hear the sound. nvidia_drm.modeset=1 is set in bootloader. Needless to say it works if you disable the discrete gpu feature, but imagery is distorted (doesn't happen when manually running with --command=/bin/bash and WINEPREFIX=~/.var/app/com.usebottles.bottles/data/bottles/bottles/X/ gamescope -f -w 1920.0 -h 1080.0 -W 1920.0 -H 1080.0 -- /home/mrsteyk/.var/app/com.usebottles.bottles/data/bottles/runners/soda-7.0-9/bin/wine64 GAME)

mrsteyk commented 1 year ago

If "distorted imagery" piques your interest (bg video works on discrete)

2023-02-24T19:12:07,120384523+05:00 2023-02-24T19:14:38,276734718+05:00

xlacroixx commented 1 year ago

Not using NOVIDEO Optimus, as I am on a desktop with GTX 1060 6GB, but I had the same issue (no window with gamescope and app in background).

Followed this workaround; gamescope now pops up.

Basically, try to run bottles with (assuming Flatpak): flatpak run --env=GBM_BACKENDS_PATH=/usr/lib/x86_64-linux-gnu/GL/nvidia-XXX-YY-ZZ/extra/gbm com.usebottles.bottles

Replace nvidia-XXX-YY-ZZ with the version you find by running flatpak run --command=ls com.usebottles.bottles /usr/lib/x86_64-linux-gnu/GL.

Heus-Sueh commented 3 months ago

I recommend you try to run it again now with the new drivers, I couldn't even play with gamescope enabled now it seems to be working