Skip to content

Conversation

@MichealReed
Copy link
Contributor

@MichealReed MichealReed commented Feb 11, 2025

We are now building the latest dawn. Specific commits can be pinned by adding a commit hash in cmake/gpu.cmake.

git fetch --depth=1 https://dawn.googlesource.com/dawn <commit hash>

  • Removes dependency on external webgpu dependency
  • Builds and links gpu.cpp + dawn in cmake/gpu.cmake.
  • See cmake/example and the CMakeLists.txt files in most examples to easily link in other projects.
  • Fixes a MSVC min/max overload problem in the render example.

Please try a few examples on other platforms and let me know if there are any issues 👍

From examples/hello_world
cmake -S . build/ -DCMAKE_BUILD_TYPE=Release

cmake --build build/ --config Release

@austinvhuang austinvhuang self-requested a review February 12, 2025 20:27
@MichealReed
Copy link
Contributor Author

MichealReed commented Feb 17, 2025

With the new commits, all the examples should compile for emscripten and output files in the build folder for js, wasm, and html.

@austinvhuang let me know if you are cool with changing the import to "webgpu.h" vs "webgpu/webgpu.h". This makes CMake life easier as none of the generation from dawn outputs as "webgpu/webgpu.h".

I needed to also rename the main function in half.cpp. Since this is included via gpu.hpp it causes conflicts with the main from the run program in examples. With gpu.cpp being a library we should avoid any use of main within included files.

Try it with:

cd examples/hello_world
emcmake cmake -S . -B ./build_web -DCMAKE_BUILD_TYPE=Release
cmake --build build_web --config Release
python3 -m http.server 8080 --d build_web

@MichealReed MichealReed changed the title CMake + Dawn Build Refactor CMake + Dawn + Emscripten Build Refactor Feb 17, 2025
@austinvhuang austinvhuang self-assigned this Feb 19, 2025
@austinvhuang
Copy link
Contributor

With the new commits, all the examples should compile for emscripten and output files in the build folder for js, wasm, and html.

@austinvhuang let me know if you are cool with changing the import to "webgpu.h" vs "webgpu/webgpu.h". This makes CMake life easier as none of the generation from dawn outputs as "webgpu/webgpu.h".

I needed to also rename the main function in half.cpp. Since this is included via gpu.hpp it causes conflicts with the main from the run program in examples. With gpu.cpp being a library we should avoid any use of main within included files.

Try it with:

cd examples/hello_world emcmake cmake -S . -B ./build_web -DCMAKE_BUILD_TYPE=Release cmake --build build_web --config Release python3 -m http.server 8080 --d build_web

Replying here for visibility - but as discussed in discord, let's try the "webgpu.h" w/o the path. There's probably some fixes in the Makefiles but we can workshop that in the dev branch before merging to main.

@austinvhuang austinvhuang merged commit 1193fb1 into AnswerDotAI:dev Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants