You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
gem 2d133e56d7 no message 2 months ago
..
states no message 2 months ago
CMakeLists.txt no message 2 months ago
WGPUBuffer.cpp no message 2 months ago
WGPUBuffer.h no message 2 months ago
WGPUCommandBuffer.cpp no message 2 months ago
WGPUCommandBuffer.h no message 2 months ago
WGPUDef.h no message 2 months ago
WGPUDescriptorSet.cpp no message 2 months ago
WGPUDescriptorSet.h no message 2 months ago
WGPUDescriptorSetLayout.cpp no message 2 months ago
WGPUDescriptorSetLayout.h no message 2 months ago
WGPUDevice.cpp no message 2 months ago
WGPUDevice.h no message 2 months ago
WGPUEMSImpl.cpp no message 2 months ago
WGPUExports.h no message 2 months ago
WGPUFrameBuffer.cpp no message 2 months ago
WGPUFrameBuffer.h no message 2 months ago
WGPUInputAssembler.cpp no message 2 months ago
WGPUInputAssembler.h no message 2 months ago
WGPUObject.h no message 2 months ago
WGPUPipelineLayout.cpp no message 2 months ago
WGPUPipelineLayout.h no message 2 months ago
WGPUPipelineState.cpp no message 2 months ago
WGPUPipelineState.h no message 2 months ago
WGPUQueryPool.cpp no message 2 months ago
WGPUQueryPool.h no message 2 months ago
WGPUQueue.cpp no message 2 months ago
WGPUQueue.h no message 2 months ago
WGPURenderPass.cpp no message 2 months ago
WGPURenderPass.h no message 2 months ago
WGPUSampler.cpp no message 2 months ago
WGPUSampler.h no message 2 months ago
WGPUShader.cpp no message 2 months ago
WGPUShader.h no message 2 months ago
WGPUSwapchain.cpp no message 2 months ago
WGPUSwapchain.h no message 2 months ago
WGPUTexture.cpp no message 2 months ago
WGPUTexture.h no message 2 months ago
WGPUUtils.cpp no message 2 months ago
WGPUUtils.h no message 2 months ago
readme.md no message 2 months ago

readme.md

WebGPU on WASM by Emscripten

Based on Cocos Creator v3.6.2, emsdk 3.1.17.

WebGPU explainer: https://gpuweb.github.io/gpuweb/explainer/

About WebGPU

What is WebGPU

distinguished from WebGL:

WebGPU is a proposed Web API to enable webpages to use the system’s GPU (Graphics Processing Unit) to perform computations and draw complex images that can be presented inside the page. This goal is similar to the WebGL family of APIs, but WebGPU enables access to more advanced features of GPUs. Whereas WebGL is mostly for drawing images but can be repurposed (with great effort) to do other kinds of computations, WebGPU has first-class support for performing general computations on the GPU.

Why WebGPU

There it is.

Why not write in typescript

Same to "why do it in c++ and then compile into wasm", in which way we can share other upper-level scheduler logic implementation instead of implement it again in typescript.

Native Implementation

Compile

Environment

unix make is needed because of emscripten compile tool chain, so we have set up extra environment deployment on Windows:

make coreutils libiconv libintl

see details at emscripten.

after emscripten is deployed, type emcc -v in cmd/zsh, shown as below:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.17 (fbc532773d84d2bd7da876275671970e792ad1cd)
clang version 15.0.0 (https://github.com/llvm/llvm-project 17e4c217b66305e60657a48f10fe3c428c2fe4d2)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: D:\project\emsdk\upstream\bin

the output is slightly different from on mac.

Custom

All the WGPU C++ files are in engine-native\cocos\renderer\gfx-wgpu. Modifications are applied only after manually compiling(next phrase), you need to copy the generated .js and .wasm to engine\native\external\emscripten\webgpu and engine\cocos\webgpu respectively and replace the original.

Compile

If any modification wants to applied in C++, cd to engine-native\cocos\renderer\gfx-wgpu and run:

emcmake cmake .

emmake make

this will generate the .js and .wasm file.

Implementation

C++ part

Same to other backends, all the graphics apis are included in webgpu.h.

TODO;