eliemichel / LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
https://eliemichel.github.io/LearnWebGPU
MIT License
90 stars 23 forks source link

step010: adapter NotFound #7

Closed rollschild closed 1 year ago

rollschild commented 1 year ago

Hi,

I'm on step010. After build succeeded I ran into this error when running the executable (with my custom logging):

WGPU instance: 0x417ed0
init!
window:0x426060
surface: 0x47c2b0
Requesting adapter...
Could NOT get WebGPU adapter: NotFound
Got adapter: 0
thread '<unnamed>' panicked at 'invalid AdapterId', src/lib.rs:186:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
[1]    28012 IOT instruction (core dumped)  ./build/src/App

Basically the error is Could NOT get WebGPU adapter: NotFound. So it successfully initialized window, found the surface, but somehow an adapter could not be found/initialized?

I'm using wgpu-native, built for Wayland on an Intel graphics laptop. I'm not sure whether it's my code (basically same as yours), or Wayland, or wgpu-native, or the graphics card itself is causing this error. Any help would be greatly appreciated. Thank you!

eliemichel commented 1 year ago

Okey the problem is that I did not wire Wayland up properly in glfw3webgpu, but there is an easy fix: in glfw3webgpu.c line 47 switch the default WGPU_TARGET to WGPU_TARGET_LINUX_WAYLAND instead if WGPU_TARGET_LINUX_X11.

Sorry I did not spend time looking for a way to automate this because once this is integrated in upstream GLFW I can use GLFW macros (well actually I could use them already, btu hopefully it will soon get merged to I'll do an update of all branches when that happens).

rollschild commented 1 year ago

Hey @eliemichel thanks for the quick reply! However I already changed WGPU_TARGET to WGPU_TARGET_LINUX_WAYLAND myself because otherwise it wouldn't compile. cmake build would give me errors. The adapter NotFound error happens after I made the change, during runtime.

eliemichel commented 1 year ago

Does the adapter initialize well if you don't specify a surface? (adapterOpts.compatibleSurface = nullptr;)

And did you mean you compiled wgpu-native yourselves in the original post? If so, which commit?

rollschild commented 1 year ago

@eliemichel Hey, somehow it works now. Not sure what changed, but it's very likely because I pulled in Vulkan dependencies like I did here.

Surprisingly, when enumerating adapter features, wgpu-native's output is tidier than dawn. Here is the features output I got using wgpu-native:

Adapter features:
 - 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 1610612737
 - 1610612738
 - 1610612739
 - 1610612740
 - 1610612741

and those large numbers at the bottom also differ from the 1002s I got from dawn. Also, there is no warning here, though I got warnings using dawn.

rollschild commented 1 year ago

Closing this issue since issue fixed. Thanks!

eliemichel commented 1 year ago

These large numbers are backend-specific features. They are intentionnally starting at different offsets to avoid conflict, more details here ;)