My plan is to add a new backend by enabling WebGPU in OpenCV.js. There have been many sophisticated GPU backends including Cuda,OpenCL,Vulkan and Halide, these GPU backends can provide reference for porting some kernels' shader code of OpenCV GPU backend to WebGPU. The concepts of pipeline and buffer of OpenCV Vulkan backend have many functions that are similar to WebGPU API, so I will try to write a library to enable emscripten to convert the used Vulkan API to WebGPU API. Specifically, the mapping from OpenCV Vulkan backend to OpenCV.js using WebGPU can be roughly divided into three parts. First of all, mapping Vulkan buffer to WebGPU buffer to access the storage of WebGPU.Secondly, mapping Vulkan API calls for pipeline and command buffer to WebGPU API. Thirdly I’ll reuse Vulkan's shaders. It’s feasible to reuse Vulkan’s shader directly in Chrome. Another possible approach is using SPIRV-Cross to convert SPIR-V in Vulkan shader to readable, usable and efficient GLSL/HLSL.



Jiang Hao


  • Zhiwen Wu