kainino0x / webgpu-cross-platform-demo

Barebones demo of WebGPU cross-platform (web/native) via CMake/Emscripten
https://kai.graphics/webgpu-cross-platform-demo/
75 stars 7 forks source link

Verify native build on Linux and Windows #15

Closed shrekshao closed 1 year ago

shrekshao commented 1 year ago

I got

main.cpp:254:74: error: ambiguous overload for ‘operator=’ (operand types are ‘wgpu::Surface’ and ‘WGPUSurface’ {aka ‘WGPUSurfaceImpl*’})
  254 |   window->surface.handle = CreateSurface(instance, display, &windowHandle);

Not sure what compile flag changed. But just make CreateSurface return wgpu::Surface instead of WGPUSurface which is good anyway.

The build and run work.

I added cmake/modules/Findglfw3.cmake to solve the cmake find_package(glfw3) issue and then cmake ../.. setup the project successfully. I tried build using Visual Studio 2019 and got some build error in main.cpp and in dawn. I never tried building dawn with VS anyway though. cmake ../.. -GNinja complains about not setting cxx compiler. So I just stopped there. I don't have this build on windows.

I used VS 2022 to open the sln generated by cmake and managed to build and run the demo.

(regards to https://github.com/kainino0x/webgpu-cross-platform-demo/pull/11#issuecomment-1354298071)

shrekshao commented 1 year ago

Interestingly @bitsauce and I tried to build on windows at the same time. I used cmake module and he used vcpkg to config glfw on windows. I cherry-picked some of his changes and added how to config glfw on win manually or using vcpkg to the README.md