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

Building Error using Emscripten with WebGPU #317

Open
mingweiLIU opened this issue Oct 10, 2024 · 11 comments
Open

Building Error using Emscripten with WebGPU #317

mingweiLIU opened this issue Oct 10, 2024 · 11 comments

Comments

@mingweiLIU
Copy link

Hi, I am building DiligentEngine using Emscripten on Windows with WebGPU, and I used dawn as the native implementation of WebGPU, there are a lot of type name errors, such as :

DiligentCore/Graphics/GraphicsEngineWebGPU/src/WebGPUResourceBase.cpp:78:13: error: use of undeclared identifier 'wgpuBufferGetMapState'
if (wgpuBufferGetMapState(BufferInfo.wgpuBuffer) == WGPUBufferMapState_Unmapped)

/DiligentCore/Graphics/GraphicsEngineWebGPU/include\WebGPUTypeConversions.hpp:58:1: error: unknown type name 'WGPUMipmapFilterMode'; did you mean 'WGPUFilterMode'?
WGPUMipmapFilterMode FilterTypeToWGPUMipMapMode(FILTER_TYPE FilterType);

and there seems no document about how to build DiligentEngine to run on the browser with WebGPU.

@TheMostDiligent
Copy link
Contributor

On Windows, did you build it by setting DILIGENT_NO_WEBGPU=OFF CMake variable?

When building for the Web, WebGPU backend is enabled by default. To use it, you initialize it like any other backend.
Here is an example.
The only caveat is that the device needs to be preinitialized in java script.

@mingweiLIU
Copy link
Author

mingweiLIU commented Oct 12, 2024

after setting DILIGENT_NO_WEBGPU OFF there is no conflict while some errors about JSON parsing, the errors just like:
In file included from E:/DilligentEngine/webgpu/DiligentTools/RenderStateNotation/src/RenderStateNotationParserImpl.cpp:27: In file included from E:/DilligentEngine/webgpu/DiligentTools/RenderStateNotation/include\pch.h:36: E:/DilligentEngine/webgpu/build/Emscripten/DiligentTools/RenderStateNotation/parser_headers\generated/CommonParser.hpp:83:10: error: no matching member function for call to 'get_to' 83 | Json.get_to(pObject); | ~~~~~^~~~~~ E:/DilligentEngine/webgpu/DiligentTools/RenderStateNotation/src/RenderStateNotationParserImpl.cpp:70:9: note: in instantiation of function template specialization 'Diligent::ParseRSN<Diligent::PipelineStateDesc, true>' requested here 70 | ParseRSN(Json["PSODesc"], Type.PSODesc, Allocator); | ^ E:/DilligentEngine/webgpu/DiligentTools/ThirdParty/json/single_include/nlohmann\json.hpp:21100:17: note: candidate template ignored: requirement 'detail::has_from_json<nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, Diligent::PipelineStateDesc, void>::value' was not satisfied [with ValueType = Diligent::PipelineStateDesc] 21100 | ValueType & get_to(ValueType& v) const noexcept(noexcept(

@TheMostDiligent
Copy link
Contributor

What is your build setup?

@mingweiLIU
Copy link
Author

mingweiLIU commented Oct 14, 2024

Environment:Windows & Emscripten SDK 3.1.65 & Ninja 1.10.2
generation command:emcmake cmake -S . -B ./build/Emscripten -G "Ninja" -DDILIGENT_NO_WEBGPU=OFF
build command:cmake --build ./build/Emscripten

@TheMostDiligent
Copy link
Contributor

I am now confused what you trying to do.

  • When you are building for the Web using Emscripten (on any platform, Windows, Mac or Linux), Dawn or any other native implementation is not needed, WebGPU headers are provided by Emscripten. Also, DILIGENT_NO_WEBGPU=OFF is set by default and does not need to be set explicitly. WebGPU is enabled automatically.
  • You need Dawn if you want to use WebGPU backend when running native application (e.g., on Windows, you will be able to select WebGPU backend when running Windows application).

@TheMostDiligent
Copy link
Contributor

Did you follow the Emscripten build instructions?

@mingweiLIU
Copy link
Author

Yes,I followed the instuctions, and the reason why I used -DDILIGENT_NO_WEBGPU=OFF is that I had set the WebGPU ON and used dawn to build native application, I used the option to force it to be off.

@TheMostDiligent
Copy link
Contributor

If you are building for the Web, please follow these instructions that detail how to build and run the samples in the browser.

If you are building native application and want to enable WebGPU, use -DDILIGENT_NO_WEBGPU=OFF. You should not need anything besides that.

@mingweiLIU
Copy link
Author

Yes, I followed the instructions for build_and_run_emscripten, the errors are same.

@TheMostDiligent
Copy link
Contributor

Honestly, I don't know what the problem is. Here is the last CI build that uses same setup and works without issues

@mingweiLIU
Copy link
Author

There may be some errors in my compile environment since cmake log shows can‘t find the ASM compiler, however I can't fix it currently.

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

No branches or pull requests

2 participants