Search code examples
webglwebgpu

Inrterop between WebGL2 and WebGPU


My question is short: Is it possible, and if so how, to read a texture or framebuffer created by WebGPU in WebGL2?

I've googled, and the only thing I found is this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1200466, but I can't say, that i fully understand it, or where the documentation is.

The overall goal is to create a render engine in WebGPU, copy it to a WebGL texture and use it in a QML app compiled for WebAssembly. QML does not yet support WebGPU, and it's unclear when support will come.


Solution

  • There is no special interop between webgl and webgpu. In WebGL you can call texImage2D and pass it a canvas element. In WebGPU you can call copyExternalImageToTexture and pass it a canvas element. In both cases that can be a 2d canvas, a webgl canvas, a webgl2 canvas, a bitmap canvas or a webgpu canvas