go-webgpu
go-webgpu copied to clipboard
Q: WebAssemble Target possible?
Ahoy
I am not firm with webgpu so far and am wondering if it is also possible to target Wasm and display in a canvas? Would it be possible to create such a surface? Would that be possible with gio? How would the surface work?
Thanks a lot and for any hint in advance
wasm isn't supported currently but it is definitely possible but because Go doesn't support cgo for js/wasm target, wgpu-native
can't be used there. the javascript webgpu api will need to be wrapped via syscall/js
instead.
also that will mean wasm target will be limited in someways, for example wgpu-native
supports glsl and spirv shaders and browsers only support wgsl
also not to mention current browser support for WebGPU api is lacking and behind the flags whereas wgpu-native
can also run on top of WebGL2 while providing WebGPU api so it has wider support.
Regarding wrapping syscall/js there are 2 approaches to make life easier
https://github.com/hack-pad/safejs
https://github.com/inkeliz/go_inkwasm
I am using go_inkwasm, and yet to use safejs yet.
@rajveermalviya
https://caniuse.com/?search=webgpu might be good to add to the Reamme somewhere ? so people can see its there but not turned on.
I was thinking of hosting your demos on fly.io to show things off.
I am starting on a PR for this based on https://github.com/mokiat/wasmgpu.