go-webgpu icon indicating copy to clipboard operation
go-webgpu copied to clipboard

Q: WebAssemble Target possible?

Open nea opened this issue 2 years ago • 4 comments

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

nea avatar Aug 03 '22 16:08 nea

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.

rajveermalviya avatar Aug 03 '22 17:08 rajveermalviya

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.

gedw99 avatar Mar 18 '23 13:03 gedw99

@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.

gedw99 avatar Mar 18 '23 13:03 gedw99

I am starting on a PR for this based on https://github.com/mokiat/wasmgpu.

kkoreilly avatar Jul 26 '24 23:07 kkoreilly