wasn’t there a plan for WebGPU to support SPIR-V until Apple killed it, making WGSL (a source language rather than an IR) the only supported way of shipping kernels in WebGPU?
To be fair, there are real issues with SPIR-V, and WGSL was a nice opportunity for a clean break from GLSL-like (aka C-like) shading languages, and I think it turned out rather nice (if you’re not familiar, it’s definitely got a more Rusty syntax, and gets rid of a bunch of implicit conversions that GLSL did)
This article names a few things as horrors that don’t feel that horrible and a few others I feel are a bit hard to follow. Mainly it doesn’t explain why a source language is better; you need to parse the thing and I think there has historically been more room for ambiguity in source languages vs an IR like SPIR-V. And certainly TFA’s opinion of SPIR-V is higher for some reason.
From briefly looking at WGSL it looked only superficially Rusty, and verbose in a way you might expect of something trying to be both a source language and effectively an IR, but my own impression is too poorly informed to be worth much
I think the issue with SPIR-V (from the author’s standpoint) is that it’s an IR for a driver’s shader compiler talking to hardware, but the semantics it encodes are too low-level and fussy to easily use as an intermediate between different shader source formats.
A graphics driver can generate a subset of SPIR-V that its hardware likes, but if SPIR-V were used for WebGPU then random websites can send your browser SPIR-V, and the entire semantic model comes into scope (even the parts that don’t make sense to use together).
SPIR-V was originally designed as an IR for OpenCL, which started out source only. Why was it OK for OpenCL but not for WGSL, which went back to where OpenCL started - shipping source strings to be compiled at runtime?
Reminds me of Embrace Extend Extinguish, I am cautiously optimistic…
Huge news! Finally some proper cross-vendor pollination. Can’t wait to ditch stacks upon stacks of #ifdef ensuring GLSL and HLSL compatibility.
Have you tried cross-compilers? Bevy engine uses WGSL exclusively, and translates it to HLSL/Metal/SPIR-V as needed.
https://github.com/gfx-rs/wgpu/tree/trunk/naga
wasn’t there a plan for WebGPU to support SPIR-V until Apple killed it, making WGSL (a source language rather than an IR) the only supported way of shipping kernels in WebGPU?
Yes, that’s more or less what happened.
To be fair, there are real issues with SPIR-V, and WGSL was a nice opportunity for a clean break from GLSL-like (aka C-like) shading languages, and I think it turned out rather nice (if you’re not familiar, it’s definitely got a more Rusty syntax, and gets rid of a bunch of implicit conversions that GLSL did)
See Horrors of SPIR-V for a nice article on the subject.
This article names a few things as horrors that don’t feel that horrible and a few others I feel are a bit hard to follow. Mainly it doesn’t explain why a source language is better; you need to parse the thing and I think there has historically been more room for ambiguity in source languages vs an IR like SPIR-V. And certainly TFA’s opinion of SPIR-V is higher for some reason.
From briefly looking at WGSL it looked only superficially Rusty, and verbose in a way you might expect of something trying to be both a source language and effectively an IR, but my own impression is too poorly informed to be worth much
I think the issue with SPIR-V (from the author’s standpoint) is that it’s an IR for a driver’s shader compiler talking to hardware, but the semantics it encodes are too low-level and fussy to easily use as an intermediate between different shader source formats.
A graphics driver can generate a subset of SPIR-V that its hardware likes, but if SPIR-V were used for WebGPU then random websites can send your browser SPIR-V, and the entire semantic model comes into scope (even the parts that don’t make sense to use together).
SPIR-V was originally designed as an IR for OpenCL, which started out source only. Why was it OK for OpenCL but not for WGSL, which went back to where OpenCL started - shipping source strings to be compiled at runtime?