TL;DR
Can a texture created in C/C++ (e.g. in a node addon) can be shared with browser-side WebGPU via a handle?
Can a texture created browser-side can be shared with native WebGPU, via a handle?
Context
NB: My own problem is on macOS platform, but this question is not specific to any platform.
I'm a beginner in WebGPU, writing a more general purpose library (node-syphon) that can be used in Electron, and that:
- Consumes an external Metal texture /
IOSurface
and send its pixels via IPC to the browser (renderer process) to be displayed in anHTMLCanvasElement
; - Gets an
HTMLCanvasElement
content (pixels asUint8Array
for now) and send it via IPC to node (main process) to be passed to an external library.
Performances are obviously quite bad, but for the time being, I'm also able to get a handle from an Electron window rendered offscreen and treat it on C++ side in a node addon.
Question
Is it and how would it be possible to:
- Create a WebGPU texture C++-side, get a handle from this texture and treat it in the browser?
This comment in Electron suggests it is possible (note that Electron's sharedTextureHandle
is actually an IOSurface
on macOS and a HANDLE
to the shared D3D11 texture on Windows).
- Create a WebGPU texture in the browser, get a handle and send it to C++ native WebGPU?