Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails with 'Error in Surface::configure: parent device is lost' when Nvidia GPU is selected on Linux #2519

Open
heavyrain266 opened this issue Mar 1, 2022 · 14 comments
Labels
api: vulkan Issues with Vulkan area: correctness We're behaving incorrectly help required We need community help to make this happen. platform: hybrid graphics Issues with machines with attached integrated and dedicated gpus platform: wayland Issues with integration with linux/wayland type: bug Something isn't working

Comments

@heavyrain266
Copy link
Contributor

heavyrain266 commented Mar 1, 2022

Description
I have tried to run any of examples and my program with HighPerformance (Vulkan) device settings, GL backend fails to LLVMpipe (wgpu 0.12).

Currently running Vulkan based Wayland Compositor on this GPU as well as vkcube outputs that nvidia is in use Selected GPU 1: NVIDIA GeForce GTX 1650 Ti, type: 2

Repro steps
Try to run any wgpu-based program or example on laptop with nvidia as descrete gpu.

Expected vs observed behavior
Program should run just fine but instead throws error 'Error in Surface::configure: parent device is lost'

Extra materials
Running with wgpu::PowerPreference::LowPower outputs radeon card and works as you can see on image bellow.

AdapterInfo {
    name: "AMD RADV RENOIR",
    vendor: 4098,
    device: 5686,
    device_type: IntegratedGpu,
    backend: Vulkan,
}

Platform
Linux 5.15.24_1 on HP Omen 15 with Nvidia 1650ti

@kvark kvark added area: correctness We're behaving incorrectly help required We need community help to make this happen. type: bug Something isn't working labels Mar 7, 2022
@heavyrain266
Copy link
Contributor Author

After talk with developers of Wayland implementation in Rust, only way to possibly fix this issue is checking if given Compositor explicitely advertises DMA-BUF v4 control. DMA-BUF is efficient replacement for Shared Memory (shm) for sending buffers directly to GPU and don't process them in CPU. Problem is that, it's not really popular in Compsositors to have such thing implemented manually but backend libraries such as smithay or wlroots are working on it.

I think wgpu should open connection with Compositor through wayland-rs crate and poll DMA-BUF related informations from Compositor which will send back informations about supported version. If version of DMA-BUF control is lower than 4, wgpu should close connection and use fallback (low power) device instead.

@jimblandy
Copy link
Member

@heavyrain266 I guess I'd like to understand better why vkcube, say, has no trouble presenting using the NVIDIA back end, but wgpu cannot manage it. Can't we just do what they're doing?

@heavyrain266
Copy link
Contributor Author

heavyrain266 commented Apr 18, 2022

@heavyrain266 I guess I'd like to understand better why vkcube, say, has no trouble presenting using the NVIDIA back end, but wgpu cannot manage it. Can't we just do what they're doing?

Thats quite complicated topic generally, few months ago they added Wayland support in drivers but not yet everything works as it should. Vulkan is complicated as well and you need to dispatch some globals and WSI integration in renderer, like WaylandSurfaceKHR, somethig with memory in name etc.

Wayland uses Linux's DMA-BUF (Direct Memory Access) API which is replacement for SHM (Shared Memory) , Both APIs are used to share memory with Compositor to create client buffer which is composited with display buffer, now it will display it as toplevel surface aka "window". Rest is handled by winit which setup globals for xdg-shell to request "window management" events from server etc.

From my knowledge Nvidia doesn't even implement vulkan dmabuf extension and information and selected card by vkcube must he missleading and use integrated gpu instead. Same thing must happen to my Compositor which uses vulkan as well because nvidia tools shows that nvidia card uses it but this will lead to crash on start.

At the end, doesn't matter if you try to display vulkan program on gles2 or vulkan based Compositor, your client and driver must support dmabif extension and dispatch some globals.

@jimblandy
Copy link
Member

Okay. I'm going to work on the assumption that we can't generally expect to do better than vkcube, so once that can use the NVIDIA adapter we'll revisit this.

@viandoxdev
Copy link

From my knowledge Nvidia doesn't even implement vulkan dmabuf extension and information and selected card by vkcube must he missleading and use integrated gpu instead.

From my tests: vkcube does use the nvidia gpu, but it just runs on xwayland instead.
On another note, using wgpu with an nvidia gpu on xwayland results in a validation layer error (also present on vkcube), that crashes the process, but that would otherwise work (vkcube runs fine when ingoring it).

@heavyrain266
Copy link
Contributor Author

heavyrain266 commented May 12, 2022

From my tests: vkcube does use the nvidia gpu, but it just runs on xwayland instead. On another note, using wgpu with an nvidia gpu on xwayland results in a validation layer error (also present on vkcube), that crashes the process, but that would otherwise work (vkcube runs fine when ingoring it).

Try running it with WAYLAND_DISPLAY=wayland-1 vkcube and/or -DCUBE_WSI_SELECTION=WAYLAND, it is intended behaviour that it runs on XWayland by default.

@louismhowe
Copy link

Hi, I have this problem on Ubuntu 22.04.

I have a somewhat unusual multi-GPU setup (3xRTX 3090 + 1xAMD GCN5 integrated GPU), with the monitor currently attached to one of the RTX 3090s. In my case, I am using Xorg rather than Wayland, and vkcube works fine.

I also tried playing with WGPU_ADAPTER_NAME and WGPU_BACKEND, but neither seems to have any effect, no matter what values I use.

If I can help you test anything or provide more info, let me know!

@adsick
Copy link

adsick commented Mar 7, 2023

same on Ubuntu 22.10 (Wayland). HW: Ryzen 5 5600H + RTX 3060

@teoxoy
Copy link
Member

teoxoy commented Mar 7, 2023

@heavyrain266 @viandoxdev @adsick as this sounds like a wayland only issue, please try vkcube-wayland on the Nvidia dGPU and report your results.

@louismhowe could you open a new issue (since this issue seems to be related to laptops with hybrid graphics)?

@heavyrain266
Copy link
Contributor Author

If vkcube is not using sRGB then it will always work just fine. As of nvidia doesn't support sRGB surfaces on Wayland yet.

@adsick
Copy link

adsick commented Mar 7, 2023

@teoxoy I'm sorry, I don't know what you mean by "try vkcube-wayland on the Nvidia dGPU and report your results"

@teoxoy
Copy link
Member

teoxoy commented Mar 7, 2023

The vkcube-wayland executable it's part of the vulkan-tools package.

@adsick
Copy link

adsick commented Mar 7, 2023

adsick@Legion-5-15ACH6H:~$ vkcube-wayland
Selected GPU 1: NVIDIA GeForce RTX 3060 Laptop GPU, type: DiscreteGpu
vkcube-wayland: ./cube/cube.c:1373: demo_prepare_buffers: Assertion `!err' failed.
Aborted (core dumped)

@vfx1b
Copy link

vfx1b commented Jan 3, 2024

Hi, Im also having this issue, im running kde-wayland on void-linux. First noticed it because halloy (irc client built with iced-rs) broke. and now i cant even run basic wgpu samples. halloy did use to work, but not anymore.

vkcube-wayland Selected GPU 0: NVIDIA GeForce RTX 3070 Ti Laptop GPU, type: DiscreteGpu warning: queue 0x5627bcc97520 destroyed while proxies still attached: wl_registry@11 still attached Segmentation fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan area: correctness We're behaving incorrectly help required We need community help to make this happen. platform: hybrid graphics Issues with machines with attached integrated and dedicated gpus platform: wayland Issues with integration with linux/wayland type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants