Implementing WebGPU in Gecko
kvark.github.io
kvark.github.io
Or even whole sites! Maybe it's the long-sought revenue model for journalism ;-)
Not really the same though, the purpose of WebGPU is exposing a sandboxed GPU hardware directly to the web, not exposing just a graphical API like WebGL exposes OpenGL variants.
It currently is looking at being SPIR-V compatible. As both Vulkan and OpenCL supports SPIR-V we might use WebGPU for GPGPU in the future.
Too bad Apple not only refuse to support Vulkan, but try to prevent using SPIR-V as well.
As for Firefox, the WebGPU implementation uses the infrastructure we have for Vulkan Portability, and so consuming SPIRV is natural.
If whatever Apple does forces Khronos to be more innovative, moreso the better.
Without CUDA's winning strategy regarding multi-language support, SPIR-V and SYSCL would never had happened.
I prefer GLSL to Metal Shading Language.
Indeed, I really appreciate MSL being a C++ dialect.
SPIR-V allows you to compile from whatever you want, and avoids the hideously complex beast that is C++ needing to be part of the browser's API.
I worry that we now just count on nice languages / compilers magically appearing deus ex machina, and we end up not having any. Big multiplatform frameworks like Unity will just put a SPIR-V backend on their existing tooling.
The rest of us will be stuck with POC-quality GLSL transpiler tools, without the browser devtools and other tooling support that we slowly got over the ~10 years of WebGL history.
(I'm not saying GLSL is that excellent, just that could be heading backwards from current almost-good-enough GLSL implementation quality in WebGL.)
You see this on Android and Switch, where most Vulkan related stuff, is based on Unreal and Unity tutorials.
Now, with that said, Apple did not propose MSL to the WebGPU working group either. Apple originally proposed a hilariously underspecified fork of HLSL called WHLSL which had three goals: 1. Be a safe shading language for the web, 2. Be compatible with existing HLSL content, 3. Add pointers.
Nobody ever justified the existence of that last one to me or the rest of the group, other than making the Metal implementation slightly easier for Safari, since Metal's binding model is based on pointers, and coincidentally, the Safari pre-release only supported binding pointers, and not the standard HLSL way of doing things. But still, the WHLSL proposal was interesting to a lot of people because HLSL seemed like a good language to start from.
After a lot of debate, Apple secretly went back to the drawing board, and released a revised version of the language, WSL, which dropped the goal of HLSL compatibility but still has pointers for some reason. Nobody has ever explained why it has pointers, despite everyone continuing to ask. The goals are still there if you want to read them [0].
As they have learned the hard way with OpenCL, most devs like to be pampered with modern toiling.
Heck, it is thanks to Microsoft that we have glTF 2.0, and NVidia for any kind of usable C++ Vulkan bindings.
If you want to improve quality - anyone can contribute and improve, instead of like Apple trying to sabotage and derail.
See for example projects like dxvk, which affected Vulkan spec:
* https://www.youtube.com/watch?v=1fU4w2ZGxH4&t=12m21s
* http://jason-blog.jlekstrand.net/2018/10/transform-feedback-...
Good luck for such thing happening with anything Apple related.
But for bug reports, debugging and fixing bugs in the shader compiler, validation layers, etc they are pretty responsive to issue reports and pull requests.
With Khronos APIs, every newbie graphics developer learns to build their engine from day one.
None of which has anything to do with SPIR-V? It's a standardised intermediate language, not an API, and it has no dependency on Khronos tooling.
And if anyone wants to make a better higher level language and compiler for it to generate SPIR-V, they are always welcome.
sure there will be workarounds like building your own DSL to spriv compiler and including it on your page but I'd argue a standard high level text format leads to more collaboration / standardization / interop / knowledge sharing
I'm sure others would prefer the web had just started as sandboxed assembly
Human readability of the shader shipped from the page is a different argument, and it can have some merit, but the same could be argued against using WebAssembly for instance which is not very human readable in comparison with JavaScript. I don't think it's a strong argument against using it.
I think if you want to compile shaders from source, you are free to include your favorite transpiler as WebAssembly, like glslang. That's currently what I'm doing for my WebGPU prototype project.
GLSL's upbringing with integrated texture/samplers is a bit ridiculous in a separable texture/sampler world, like in Vulkan. You need to create an integrated texture/sampler with the sampler2D constructor, and then immediately use it. The GLSL spec specifically says you can't pass it to your own user-created functions, I'm guessing because they didn't trust platform vendors to write working compilers?
But glslang checks for it too, despite being the only GLSL compiler in the toolchain: https://github.com/KhronosGroup/glslang/blob/bd97b6f9f2132fa...
You also can't put any binding object like texture2D in a struct, even though you can pass it between functions? The whole enterprise really feels like it was limitations in baby's-first-compiler that added a bunch of weird restrictions.
HLSL is a C++-esque derivative that supports quite a bit more functionality than you probably imagine, and a lot less of the goofy limitations, given that it has a single compiler stack made by a company with competent compiler engineers.
An advantage of SPIR-V is that unlike both text-based programming languages and traditional machine code, SPIR-V is very very easy for machines to read and write — even for JS code — and it has a structure designed to be (mostly) cleanly extensible.
The thing is, a text format is the worst format for interoperability between consoles, desktop and web. Having something like SPIR-V is more akin to LLVM for programming languages. LLVM doesn't preclude the existence of C, C++, etc, but it strictly benefits the ecosystem (which now includes Rust, Haskell, etc). In the same way, I see SPIR-V having the same potential as the interchange format for all the major IHVs.
WebGL1 : DirectX9 :: WebGPU : DirectX12
Or
WebGL1 : OpenGLES1 :: WebGPU : Vulkan