eliemichel / WebGPU-distribution

Distributions of WebGPU for native and web development, easy to integrate and interchangeable.
MIT License
159 stars 29 forks source link

Compiling `dawn` error: set_property could not find TARGET update_mappings #7

Closed rollschild closed 9 months ago

rollschild commented 1 year ago

Hi,

First of all thanks for this cool project! I've been following the Learn WebGPU, although it's still WIP it's been very useful so far! And I'm amazed by how quickly bugs got fixed. Previously I ran into the markupsafe missing error but I noticed that it had been already fixed.

I'm seeing another error right now while compiling dawn on Linux (NixOS) for Wayland:

CMake Error at webgpu/cmake/FetchDawn.cmake:77 (set_property):
  set_property could not find TARGET update_mappings.  Perhaps it has not yet
  been created.
Call Stack (most recent call first):
  webgpu/CMakeLists.txt:21 (make_dawn_available)

I see that it was due to set_property(TARGET update_mappings PROPERTY FOLDER "External/GLFW3") in webgpu/cmake/FetchDawn.cmake but I'm not sure how to fix it. Could you please help? Thanks!

eliemichel commented 1 year ago

Okey I guess we can wrap this in some if (TARGET update_mappings) because the existence of the target may depend on the OS! (This line is just here so that target are well organized visually in an IDE, not super important)

rollschild commented 1 year ago

@eliemichel Thanks for the tip! Build succeeded. Ran into another error at run time. Not sure if it's me or something else. I will open another issue if I couldn't figure it out myself.

rollschild commented 1 year ago

Well, during cmake . -B build, I saw the following log:

-- Dawn build Wayland support: OFF
-- Dawn build X11 support: ON

Does it mean wayland support for Dawn is turned off?

eliemichel commented 1 year ago

Oh, I think you can simply add set(DAWN_USE_WAYLAND ON) at the beginning of your CMakeLists.txt.

Do you know if there is a way to automatically figure out in CMake whether the build targets a Wayland environment? If so I will add this automatically in FetchDawn.cmake

(Also, if you don't want to restart the build from scratch, look for DAWN_USE_WAYLAND:BOOL=OFF in build/CMakeCache.txt and switch is to ON.)

rollschild commented 1 year ago

@eliemichel Hey thanks for the reply. Actually last night I found this line in Dawn's source code CMakeLists.txt so I manually set(DAWN_USE_WAYLAND ON) in FetchDawn.cmake and it did fix this error.

However there is another issue - I'm not near my personal laptop right now but it's something like Vulkan could not be loaded, while requesting the adapter. Strangely, after this error message, adapter was successfully requested but with value 0 - I think it's the nullptr value it was initialized with.

I thought they were part of the same issue so I didn't rush to post an update here. I may need to take a little while to further troubleshoot this but this is as far as I could go right now. Thank you!

eliemichel commented 1 year ago

Did you check whether other vulkan-based program run correctly on your system?

rollschild commented 1 year ago

@eliemichel You are right. I pulled in some vulkan dependencies and now it's working. Instance created. Surface created. Adapter requested with non-zero value. There are only two warnings, which I think are probably fine.

Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 0.  Skipping ICD.
Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 3.  Skipping ICD.

And these are the Adapter features logged:

Adapter features:
 - 5
 - 6
 - 7
 - 4
 - 3
 - 1006
 - 1
 - 2
 - 1005
 - 8
 - 10
 - 11
 - 1002
 - 1004
 - 1007
eliemichel commented 1 year ago

Nice :) For the record, can you give some details about "pulling in some vulkan dependencies"? Anything worth sharing to other people in a similar situation that I could add to the guide?

rollschild commented 1 year ago

@eliemichel Sure. I'm using NixOS and this is a flake-based project. My flake.nix is here. Basically it pins any dependencies that are needed for the particular project.

The Vulkan dependencies that I added are:

            # vulkan 
            glslang # or shaderc
            vulkan-headers
            vulkan-loader
            vulkan-validation-layers # maybe?
            vulkan-tools

(Note: there are definitely unnecessary dependencies in my flake.nix but this is what works for me for now.)