4 ms·
WGSL is easily the worst part of WebGPU, which I like overall. The world did not need another high-level shading language. They could have just used SPIR-V byte
by davexunit 2y ago
WGSL is easily the worst part of WebGPU, which I like overall. The world did not need another high-level shading language. They could have just used SPIR-V bytecode if it wasn't for Apple sabotage. The GPU API in SDL3, by comparison, has chosen the only sane option and just asks you to pass whatever the native shader format is.
- Rusky 2y agoThey could not "just" have used SPIR-V bytecode. WebGL already had to do a bunch of work to restrict GLSL's semantics to work in the web sandbox; whatever WebGPU chose would have had the same problem.
- mwkaufma 2y agoWGSL is defined as a "bijection" to a "subset" of spir-v -- they could have simply specced that subset.
- MindSpunk 2y agoI do not believe this is true anymore and WGSL is a "real language" now that actually requires a "real language frontend" to compile. The original spec didn't even have while loops, they expected you to effectively write the SSA graph by hand (because SPIR-V is an SSA IR). Then the design drifted as they kept adding pieces until they accidentally made an actual language again.
- pjmlp 2y agoThat was the original plan, then they created their Rust inspired language instead.
- mwkaufma 2y agoYeah exactly, that's why refusing to simply spec the bytecode at the time was exactly the sabotage that everyone called it out as.
- modeless 2y agoIn comparison to inventing a new language and three independent interoperable implementations from scratch, I think "just" is appropriate.
- johnnyanmac 2y agoWhy am I not surprised that it's Apple that continues to make the world of graphics programming even more difficult than it needs to be. > The GPU API in SDL3, by comparison, has chosen the only sane option and just asks you to pass whatever the native shader format is. I get why their don't do this, to be fair. That would mean they would need to have a proper parser for a half dozen shader models. Or at least try to promise they will make and maintain others soon.
- mwkaufma 2y agoSDL3 offers a spir-v-cross reference impl as an optional auxiliary library.
- modeless 2y agoAlso DirectX is adopting SPIR-V, so that will help in the future as well. Yes, it's true! https://devblogs.microsoft.com/directx/directx-adopting-spir-v/ https://devblogs.microsoft.com/directx/directx-adopting-spir...
- NekkoDroid 2y agoDXC can already compile to SPIR-V (with some missing features/limitations IIRC), this just effectivly replaces DXIL with SPIR-V in future shader models and makes it THE language the compiler speaks. They are also slowly but surely porting their DXC compiler (forked from Clang 3.6 I think) to upstream Clang.
- vrighter 2y agoIt's not a question of whether it can compile to spir-v, but a question of whether dx12 can consume spir-v
- davexunit 2y ago> That would mean they would need to have a proper parser for a half dozen shader models. It avoids this entirely. If you're on a system whose GPU driver only speaks DXBC and you hand it SPIR-V, that would be an error. This is what SDL GPU does. The SDL team conveniently made a small library that can cross-compile SPIR-V to the other major bytecode formats that you can integrate into your build pipeline.
- bsder 2y agoWebGPU was a total surrender to Apple, and Apple still didn't implement it. Given that Microsoft has also thrown in with SPIR-V and Apple still isn't shipping WebGPU, the next version of WebGPU should tell Apple to fuck off, switch to SPIR-V, and pick up Windows, XBox, and Linux at a stroke.
- modeless 2y agoApple is implementing it. They are just slow. There's no point in a web standard that Apple won't implement as long as they hold a monopoly on iOS browser engines.
- bsder 2y agoJust like Microsoft was slow about web standards in IE6. <rolls eyes> Tell Apple to fuck off and roll it out--designers will flock to Teh Shiny(tm). When enough designers can't run their glitzy web thing, Apple will cave.
- vetinari 2y agoGoogle and Mozilla are also pretty slow. Google still doesn't support it on more than some SoCs on their own Android, leaving the bulk of the market unsupported, never mind Linux. Mozilla also got lost somewhere.
- johnnyanmac 2y agoYeah, they weren't much faster with adopting WebGL nor Vulkan nor OpenGL ES either (even if it did indeed suck). Something tells me the business incentive isn't there as much for high performance on the web compared to desktop nor even mobile (which is starting to increase demand as Asia makes more AAA esque games for mobile). It's also not like advancement has been a priority for tech this decade so far.
- pjmlp 2y agoLets put it this way, a decade after WebGL 1.0, still there aren't any usable developer tools on browsers to sanily debug 3D rendering. To the point most studios would rather use something like streaming, where at least they enjoy the convenience of tooling like RenderDoc, PIX, Instruments, NInsight,....