I know this problem could well be on the part of Electron, but I got this one working – Rotating Cube - WebGPU Samples, so I started by posting it here. Hopefully I can get some insight.
In case it is helpful, I created a repo with a simple Electron + webgpu setup:
if compilation fails you might need to edit index.d.ts with: export const api: any;
Are you sure the cache of the browser has been reset and the latest versions of twgsl.js/twgsl.wasm have been loaded? I think it could be the explanation.
@Evgeni_Popovhttps://github.com/jeremy-coleman/OceanDemo . Not done with what I’m experimenting with so its pretty messy, but it works. just npm i npm run start. It’s using nightly build of electron, so v16 atm . I was pinning to v14 before, which is the first version of electron that added webgpu, but i found that webgpu/wgsl changes somewhat frequently for arbitrary pedantic bullshit like the name of a variable with no functionality changes , so it’d often work in electron then not in the browser any more , which is enraging. I also swapped out webpack for vite.
in addition to the obvious caching issues I also had CORS issues with loading ‘https://preview.babylonjs.com/...js’ files on the fly. So I decided to host the glslang.js etc on my own server.
@Evgeni_Popov I’m assuming this is a temporary way of including these scripts? Let me know if you want me to create an issue.
@mise do you know if its possible / how to enable spirv shaders in electron? Also, any thoughts on how to make it permanent , because google is gonna take it out / already has. I really really dont want to deal with wgsl shit for the next 2+ years. The glslang wasm compiler isn’t really going to be effective if it compiles glsl to an ever-changing wgsl spec. Also naga is another option now.
Side note: Ofc, I dont think this is ideal for electron, but probably best for the web.
The spec of WebGPU/WGSL is not final yet, so it’s expected to have some changes, but there normally should be less and less as we are gearing to v1 release.
@mise We should not have CORS issues when including these files: are you able to setup a repro? The Playground are linking to those files and it does work as expected.
In Babylon we are currently using glslang + Tint wrapped in a WASM module to convert from glsl to spir-v (glslang) and spir-v to wgsl (Tint). We are evaluating the possibility to use Naga in a WASM module instead of glslang+Tint, mostly to have a lighter dependency (currently, glslang+Tint ASM = around 2Mbytes).
We are also adding support for native WGSL in ShaderMaterial so that you are able to use features specific to WGSL (like external textures).