Some context: browser vendors are working on a successor to WebGL, and there's been a debate over what shading language to use.
A text based language would be easier for beginners (since they wouldn't need to install a separate shader compiler) and would avoid sites that need dynamic shaders having to download and run a shader compiler in the browser.
Using SPIR-V bytecode would benefit from a large amount of work put into an existing standard and an open source compiler ecosystem that many companies are already using.
It looks like a decision has been made to accept a text based language, but one that is defined based on SPIR-V semantics and is easily convertible back and forth from SPIR-V. This seems like a great trade off since if it works out it should have the main advantages of both approaches.
Re:WebGPU Shading Language
by pcwalton on Tuesday March 10, 2020 @01:08PM
(#22537262)
> A text based language would be easier for beginners (since they wouldn't need to install a separate shader compiler) and would avoid sites that need dynamic shaders having to download and run a shader compiler in the browser.
That is more or less the official rationale, but it's pretty clear that the real reason is that Apple is organizationally opposed to SPIR-V (and Khronos generally). This is a tough needle to thread, so I'm glad forward progress is being made.
Re:WebGPU Shading Language
by xenadu02 on Tuesday March 10, 2020 @05:00PM
(#22539626)
I strongly favor sticking to DRM-free text-based formats for the web. I remember learning a lot just from looking at the HTML and JS sources from web pages. It's been a great boon for the web up until now. Besides lots of apps already ship shaders as text. They get dynamically compiled and cached, just like JS does. Being text-based hasn't stopped JS from greatly improving performance.
Khronos sat on their hands for years and only moved after Apple shipped Metal and AMD dumped Mantle in their laps (I'll note that Metal came first). SPIR-V is not the be-all end-all of shader programming. Personally I don't believe we should accept some lowest-common-denominator that puts the future of GPU development in the hands of an organization with the track record Khronos has wrt managing OpenGL. That goes double for the future of WebGPU. However I recognize those are just personal opinions and reasonable people may disagree.
To those offering opinions here: If you've never written a renderer or shader can I suggest you write a toy project using both then see if you still have the same opinion?
Re:WebGPU Shading Language
by pcwalton on Tuesday March 10, 2020 @05:18PM
(#22539819)
The problem with the view-source argument is that source is often minified these days, so you need a decompiler of some sort to go from the bits on the wire to something human-readable no matter what. A pretty-printer can sometimes be simpler than an IR decompiler, but often not really.
Regardless of Apple’s motivations those still are real benefits, I think at least one major WebGL framework uses dynamic shader generation and was looking at going the bundled-shader-compiler route. Hopefully this approach cuts back on the projects that find it necessary to do that and encourages faster adoption from WebGL.
Re:WebGPU Shading Language
by kevingadd on Tuesday March 10, 2020 @01:59PM
(#22537805)
If you're willing to do dynamic shader generation as text, you can generate shader bytecode. The real question is which of the two options produces more performant shaders and faster compile times, since naively-generated shader bytecode isn't being optimized like your text is. If you care about compile times text-based can be a lot worse (this matters for the Dolphin emulator, for example)
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @04:38PM
(#22539425)
That is correct, in theory, but there is a large gap between theory and practice. How practical would it be for, say Three.JS to generate shader bytecode? Would it need to depend on a sophisticated WASM module that allows to build such bytecode? Who is going to build that?
Google has spent a lot of effort trying to answer these questions, and they got close, but in the end the text-based solution prevailed. In part, because it was easy to agree on for all parties.
Re:WebGPU Shading Language
by Jasper_ on Tuesday March 10, 2020 @04:52PM
(#22539567)
Do you not expect GLSL -> WGSL compilers in actual practice? I don't think anybody using Three.JS today would switch to writing WGSL unless they could also ingest it on WebGL.
That’s true, even if the semantics are the same (and parsing time isn’t a big factor) the assumptions for what optimizations have been applied to bytecode might be different. I remember seeing in one of the meeting notes that they didn’t expect browsers to end up making assumptions about the optimization level of the SPIR-V they ingest anyway but I don’t remember the specific rationale for that.
There’s of course also the time for the SPIR-V -> gpu native step. It would be nice if they could just cache that and skip the whole process most of the time.
Re:WebGPU Shading Language
by antoineMoPa on Tuesday March 10, 2020 @02:04PM
(#22537857)
If you want live-tweakable or generated webgpu shaders, which will be useful in many applications text based is much better as no complex tooling is required.
Re:WebGPU Shading Language
by tachyonbeam on Tuesday March 10, 2020 @03:19PM
(#22538619)
You could still build something like Shadertoy if the WebGPU shaders internally used a binary format. You would just need to have a JS or WASM library that compiles text shaders into the binary format. It's not that difficult to do, and it can absolutely run in the browser.
Re:WebGPU Shading Language
by slavik81 on Tuesday March 10, 2020 @03:42PM
(#22538827)
There's a SPIR-V text representation that maps directly to the binary representation. Even if it was given a binary, the browser could display the equivalent text representation.
Re:WebGPU Shading Language
by rubber_duck on Tuesday March 10, 2020 @02:59PM
(#22538424)
Useful to what applications ? Even writing modern JS requires a compiler stack, adding a shading language would be a matter of writing a webpack loader.
Re:WebGPU Shading Language
by throwaway34241 on Wednesday March 11, 2020 @01:36PM
(#22547946)
> However, binary form is way more compact
That’s what I might expect too, so I was surprised to find out that SPIR-V is usually substantially larger than text based shaders. It also doesn’t seem to compress optimally using standard algorithms. [1]
Re:WebGPU Shading Language
by mantap on Tuesday March 10, 2020 @09:12PM
(#22541939)
The transmission/storage size of shaders isn't important. Textures and 3D models dominate in any non trivial project. Kind of like dieting by trimming your toenails.
Re:WebGPU Shading Language
by mantap on Wednesday March 11, 2020 @08:52AM
(#22545344)
GPUs are machines for crunching data, be it graphics or NNs. I can't think of many use case where that isn't true.
Also if you anticipate the GPU being used as an accelerator, that is all the more reason to use a text based format because it allows for easy code generation.
Re:WebGPU Shading Language
by jfkebwjsbx on Wednesday March 11, 2020 @01:34PM
(#22547914)
You are wrong. Many projects use GPUs without big datasets. See ShaderToy, for instance: a lot of computation, almost no input data. Many other games, too: they may use the GPU for rendering fast yet have say 50 MiB of textures and assets only.
If you think of AAA games, ML and whatnot, of course. But I doubt anybody will use WebGPU for those, to be honest.
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @04:35PM
(#22539408)
I think the counter-argument to "but WASM?!" is that on the Web you still can use text to describe the behavior. WASM is optional. At the same time, if WebGPU picked SPIR-V binary, it wouldn't have a built-in way of programming without dependencies inside a browser.
Re:WebGPU Shading Language
by klodolph on Tuesday March 10, 2020 @04:56PM
(#22539592)
I'm not quite sure what you're saying. WASM is optional in the same way that WebGPU is optional. They both allow you to invoke code written in another language.
There's not really a good way of writing WASM without dependencies inside a browser.
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @05:18PM
(#22539814)
What I wanted to say is that we as a group want people to be able to use the browser and nothing else to develop WebGPU if they want.
WASM by itself doesn't provide new APIs, it's still just a different way to expose the Web platform. So WASM being optional doesn't limit anybody in what they can do. Having WebGPU optional does limit what you can do on the web. We want WebGPU to be available in a wide sense (accessibility, dependencies, portability, everthing).
Re:WebGPU Shading Language
by jfkebwjsbx on Tuesday March 10, 2020 @08:33PM
(#22541655)
Being able to develop with the browser has nothing to do with WebGPU being binary or text.
It seems you speak with "we", as if you were part of the committee? If that is a yes: how can we become part of that committee to amend this mistake? Who has voting rights?
Re:WebGPU Shading Language
by jcelerier on Wednesday March 11, 2020 @05:04AM
(#22544245)
We can compile and run c++ code in a browser with WASM versions of clang, why would it be any issue to compile glsl / any other language to spir-v ? That's already what almost everyone is doing with spirv-cross / shaderconductor on the desktop
Re:WebGPU Shading Language
by klodolph on Wednesday March 11, 2020 @10:06AM
(#22545938)
WebGPU doesn’t provide new APIs in the same sense that WASM doesn’t provide new APIs, they just provide alternative APIs to accomplish the same tasks, but faster.
Anything you can do with WebGPU you could do in JavaScript, in the same sense that anything you can do with WASM you can do in JavaScript. The only difference is performance.
Re:WebGPU Shading Language
by Athas on Tuesday March 10, 2020 @01:43PM
(#22537616)
Is there really such a great need to make the lowest level shader API more accessible to beginners? You can always build things on top that make a low-level API more friendly, but you can never build something below the lowest available level (short of inventing a new standard). What kind of beginners are these that want to do low-level shader programming, but without any tooling? Don't web programmers already accept the use of heavyweight build tools even for their plan old ordinary Javascript?
My enthusiasm for seeing yet another GPU language is very restricted. I simply cannot see the rational arguments in favour of this design. We were so close to having a standard IR for this stuff.
I think the goal here is for the semantics to basically be SPIR-V, and for people using SPIR-V toolchains to be able to expect WebGPU platforms with a Vulkan backend to execute basically the same SPIR-V after the conversions to/from text.
Re:WebGPU Shading Language
by interartdev on Tuesday March 10, 2020 @02:13PM
(#22537951)
Knowing Vulkan, WebGL, and OpenGL and working a bit with some of those technologies while hobbying the others, WebGPU will take about a decade to be fully adopted, and even then, only by a fraction of companies that are willing to spend manpower resources into developing something interfacing low level graphics directly.
Re:WebGPU Shading Language
by imtringued on Thursday March 12, 2020 @10:38AM
(#22557310)
I agree. Originally SPIR (without a V) was just a 1:1 copy of LLVM IR with no commitment to backwards compatibility. Every time LLVM IR changed SPIR had to change as well. This lead to two major versions of SPIR. Clearly this is not a sustainable solution. Implementing several versions of the same IR is a huge support burden for almost no benefit. Now we have the successor SPIR-V which is no longer tied to LLVM IR. Anyone can implement SPIR-V support without LLVM. There is no excuse to not use it. It's basically the same story with WebAssembly. LLVM IR wasn't good enough so someone had to actually do it properly this time.
Re:WebGPU Shading Language
by moron4hire on Tuesday March 10, 2020 @03:24PM
(#22538662)
That's because there is no rational reason. The reason this is at it all an issue is because Apple put their foot down and flat out refused to implement SPIR-V.
Re:WebGPU Shading Language
by imtringued on Thursday March 12, 2020 @10:50AM
(#22557433)
They also refused to implement WebP support. If they can't get their act together I'll still get my revenge by using a polyfill that decodes WebP images with Javascript (goodbye battery life!).
Re:WebGPU Shading Language
by moron4hire on Thursday March 12, 2020 @11:52AM
(#22558081)
The willingness of the various web consortiums to bend over backwards for individual corporations has got to end. It's making the web worse, not better.
Re:WebGPU Shading Language
by Jasper_ on Tuesday March 10, 2020 @11:21AM
(#22536166)
So this is in a weird place. It's trying to be a floor wax and a desert topping, that is, both a compile target and a human writable language, and the committee is having trouble deciding the vision and goals for the language.
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @04:25PM
(#22539310)
That's true, but also a reflection of the whole WebGPU standardization process. It tries to be low-level enough to be performant yet still human writable. I agree it's tricky, but just because it's hard to formulate the concrete goals doesn't mean that there is nothing to discover.
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @04:40PM
(#22539454)
The funniest (and saddest) thing about WGSL is that we realized there is a lot of confusion and tried to make a FAQ quickly to address that, but it got split and stuck in reviews:
Re:WebGPU Shading Language
by nullifidian on Tuesday March 10, 2020 @05:38PM
(#22540023)
We need optional SPIR-V shaders in Chrome's and Firefox's webgpu implementations, so that websites that use it wouldn't work on retrograde NIH text-based Apple platforms, forcing them to implement SPIR-V eventually.
Such standards politicking, creation of unneeded entities/standards is basically a "tech sin". They are sinners!
Re:WebGPU Shading Language
by kvark on Wednesday March 11, 2020 @09:04AM
(#22545452)
There are no technical issues with us having an extension that allows SPIR-V binaries to come in. It's a political issue, however, since it weakens WGSL positions. We'll be talking about this more with Google.
Re:WebGPU Shading Language
by kvark on Tuesday March 10, 2020 @04:30PM
(#22539356)
Apple and Microsoft investigated the possibility of specifying WebHLSL tightly. The main concern was that it's a ton of work in terms of semantics.
At the same time, SPIR-V semantics is fairly well specified, so we as a group figured that the familiar syntax of HLSL is not as important as the proper GPU behavior and our time specifying it. We've yet to see if it was the right decision - we might as well get stuck with discussing the syntax :)
Re:WebGPU Shading Language
by imtringued on Thursday March 12, 2020 @11:22AM
(#22557768)
From a technical standpoint a subset of SPIR-V that is safe to use in web browsers is exactly what is needed. However, there are IP problems that prevent direct usage of SPIR-V. [0] In short W3C needs full ownership of the spec so that it can be completely independent from Khronos. A textual representation of SPIR-V basically sidesteps these problems while still maintaining the ability to have a trivial SPIRV -> WSGL and WSGL -> SPIRV compiler.
Re:WebGPU Shading Language
by shmerl on Tuesday March 10, 2020 @03:39PM
(#22538807)
Why should Apple dictate their approach to everyone else then? If they are so resolved to remain outsiders technology wise because they are crazy bent on NIH, let them be outsiders.
I'd say everyone else should take a hard stance on this and show Apple to the door, instead of dancing under their tune.
Re:WebGPU Shading Language
by xenadu02 on Tuesday March 10, 2020 @04:43PM
(#22539493)
It's called a "standards process" for a reason. Even if you personally have a different opinion the point of a standard is to get everyone implementing it on-board with that standard.
Releasing a standard that a major member opposes and won't implement is a pointless exercise.
Re:WebGPU Shading Language
by mwkaufma on Tuesday March 10, 2020 @01:56PM
(#22537777)
Except it wasn't designed to be an "optimal target for SPIR-V" -- it was designed by Apple according to Metal's semantics, to promote Metal over Vulkan, and had to be rejiggered. It's worse, by your standard, than existing, battle-proven GLSL/HLSL toolchains.
Re:WebGPU Shading Language
by mschuetz on Tuesday March 10, 2020 @05:58PM
(#22540232)
It absolutely is driven by Apple. I've been following this for a while. I actually like having a text based shader format since I do a lot of dynamic shader generation and compilation at runtime, but I don't quite understand why it has to be something entirely different to existing shader languages.
Re:WebGPU Shading Language
by mschuetz on Wednesday March 11, 2020 @05:54AM
(#22544461)
Apple refused to support SPIRV, which Chrome (and Firefox?) already implemented, and lobbied for a text based language. Please read the minutes, I'm not going to look it up for you.
Re:WebGPU Shading Language
by hajile on Wednesday March 11, 2020 @09:29AM
(#22545625)
Apple clearly says it's not an option because of a legal dispute. If everyone else is at the negotiating table, but Apple says absolutely NO, how is that decision not driven by Apple?
Re:WebGPU Shading Language
by kvark on Wednesday March 11, 2020 @11:12AM
(#22546465)
Apple vetoes SPIR-V binary as an option. Google develops a language based on SPIR-V semantics that we agree on. It's clear that at least today, Google is mainly driving WGSL. They also see the value in WGSL outside of WebGPU context. Claiming the Apple primary role in this is ridiculous.
Re:WebGPU Shading Language
by mschuetz on Wednesday March 11, 2020 @07:06PM
(#22551770)
> Claiming the Apple primary role in this is ridiculous.
It's apple that didn't want SPIRV and insisted on something else, preferably text based. Doesn't matter who is doing that something else now, it's done because of Apple...
Which I'm not entirely a fan of because I don't think apple's history in WebGL, OpenGL and graphics makes them deserve the leverage they're getting.
Re:WebGPU Shading Language
by shmerl on Wednesday March 11, 2020 @03:30PM
(#22549536)
So how is it supposed to work in practice? Pages will ship SPIR-V and will be converted to WGSL just for Apple on the fly, or pages will ship WGSL, and it will be converted to SPIR-V on the fly for everyone else?
I surely hope not the later, let Apple pay performance price for being the root of the problem.
Re:WebGPU Shading Language
by kvark on Wednesday March 11, 2020 @07:44PM
(#22552014)
Many Web applications will just ship WGSL. This includes everything going through Three.js, Babylon.js, and hand-written web apps.
It's not even clear if Chrome or Firefox will accept SPIR-V binary as an extension at this point.
Anyway, conversion to and from SPIR-V is supposed to be straightforward and light. Our (speaking for gfx-rs community) Rust-based shader infrastructure will handle that , and the converter should be easily compilable to wasm (when it's ready).
Anyway x2, most of the time in the whole picture of creating pipelines will be spent in the driver, so whatever parsing performance difference WGSL brings to the table, be it 5% or 10%, doesn't matter, you aren't going to see that in benchmarks because of that other stuff that's going on when you are creating a pipeline.
Re:WebGPU Shading Language
by shmerl on Wednesday March 11, 2020 @10:08PM
(#22552881)
It would still be good for Firefox and Chrome to accept SPIR-V bytecode (in addition to WGSL). This way you can write some client side library, that converts SPIR-V on the fly to WGSL for crippled browsers (Apple) and use SPIR-V directly for everyone else.
I hope Mozilla and Google won't cave that way to this Apple's idiotic behavior.
Re:WebGPU Shading Language
by ericflo on Tuesday March 10, 2020 @02:22PM
(#22538020)
Yes, but if you follow the discussions, the clear consensus was to use SPIR-V. Except Apple, who came up with all kinds of technical reasons not to use it, before eventually admitting they have a legal dispute with Khronos group. Now we get this weird language that is SPIR-V in text form but not by Khronos, and suddenly there is consensus.
Re:WebGPU Shading Language
by ericflo on Tuesday March 10, 2020 @05:01PM
(#22539633)
From the meeting notes [1]:
MS: Apple is not comfortable working under Khronos IP framework, because of dispute between Apple Legal & Khronos which is private. Can’t talk about the substance of this dispute. Can’t make any statement for Apple to agree to Khronos IP framework. So
Re:WebGPU Shading Language
by FreeFull on Tuesday March 10, 2020 @12:57PM
(#22537154)
Vulkan itself supports both GLSL and HLSL (and any other shading language that can compile to SPIR-V), so you'd still usually end up writing GLSL anyway.
Re:WebGPU Shading Language
by pcwalton on Tuesday March 10, 2020 @11:45AM
(#22536427)
I'm not involved with the spec discussions, but I suspect it's just because 32-bit floats are heavily preferred on GPUs for performance reasons. If there were a lot of popular demand, I imagine 64-bit doubles could be added, but games overwhelmingly prefer 32-bit; it's mostly the scientific community that wants 64-bit.
Besides, if JS interop were the driving concern, 64-bit doubles would be the default, since that's what JS numbers are.
Re:WebGPU Shading Language
by szatkus on Tuesday March 10, 2020 @11:31AM
(#22536287)
Number type in JS is fp64 since forever (at least the interface, usually it's optimized to int32 by an engine, but if you use decimals you can be sure you have fp64 under the hood) and BigInt[0] is supported in almost all modern browsers.
Re:WebGPU Shading Language
by hajile on Wednesday March 11, 2020 @09:20AM
(#22545563)
Small correction, but it's optimized to int31 by all the current engines with the last bit used for tagging.
BigInt is now available on Firefox and Chrome (with JSC/Safari support in the works). That gives arbitrarily-large integers (with the JIT deciding the best size.
Re:WebGPU Shading Language
by mschuetz on Tuesday March 10, 2020 @05:54PM
(#22540172)
JS uses doubles by default, so no. There were times when js rendering engines used Float32Arrays for matrix and vector math because they should be faster since that's what the GPU uses, right? Turned out they were SIGNIFICANTLY slower because any math on CPU side now required casting floats to doubles back and forth.
Re:WebGPU Shading Language
by rrss on Tuesday March 10, 2020 @11:40AM
(#22536361)
Which GPUs do not have double precision arithmetic? As far as I'm aware, all of AMD's and Nvidia's from the last decade have double precision support. It may not be fast, but it's there.
Re:WebGPU Shading Language
by Jasper_ on Tuesday March 10, 2020 @11:58AM
(#22536558)
Right, the desktop GPUs have support for float64, but it's not exposed in HLSL/GLSL to the best of my knowledge. "precision highp float" in GLSL will get you 32-bit on all vendors AFAIK, you have to use OpenCL/CUDA for 64-bit floats, but it's way slower and actually sometimes emulated.
Re:WebGPU Shading Language
by yoden on Tuesday March 10, 2020 @01:19PM
(#22537358)
64 bit support has been around on the desktop for a decade at this point (Through OpenGL4 / GL_ARB_gpu_shader_fp64 / cl_khr_fp64).
Unfortunately it is not exposed in Firefox or Chrome, even if the underlying hardware supports it. I think this is creating a chicken and egg problem - if WebGL were to actually support the capabilities of the underlying hardware, maybe there would be more interest in deploying 64-bit extensions on other platforms like mobile. Even emulated support would be a win, compared to having every developer emulate fp64/i64 themselves in GLSL.
So I am also disappointed in this proposal's failure to mention 64-bit support, even as an extension. At least they're reserving the keywords, I guess.
Re:WebGPU Shading Language
by fulafel on Thursday March 12, 2020 @10:59AM
(#22557538)
Not sure what you were aiming for with the analogy, but I'm glad this made me look up the size difference between ants and humans. Humans are O(100 kg) and ants are O(1 mg), 5 orders of magnitude.
It would be interesting to see a graphics API designed to cover a range of 100 000x in performance.
Looks like Nvidia TNT had 2 GB/s of memory bandwidth in 1998 and the high end current ones have ~300-600 GB/s. That's just two orders of magnitude difference. Current fast mobile GPUs seem to get 40 GB/s so that plops to about the middle of the historical PC dGPU range, and is just 1 order of magnitude less than dGPUs.
Re:WebGPU Shading Language
by jcelerier on Thursday March 12, 2020 @06:53PM
(#22562832)
I'm saying that just because mobile device is the majority of devices does not mean that we have to care about them. Rule of the majority is never a good rule.
Re:WebGPU Shading Language
by fulafel on Friday March 13, 2020 @02:17AM
(#22565170)
Depends on who "we" are, from POV of browser vendors and makers of web graphics apps, there's certainly a compromise needed in adding features for niche users that contribute to the combinatorial explosion of tested configurations. Consider that even WebGL 2 currently is struggling to have a viable level of browser support.
WebGL mostly serves people with Intel/mobile GPUs, so will probably WebGPU if it is to survive, even though it aims to do better on the high end GPUs as well.
Re:WebGPU Shading Language
by grenoire on Tuesday March 10, 2020 @11:39AM
(#22536356)
I'm not sure if you're left over from 2007, but practically all Nvidia GPUs since 2008 have had double precision arithmetic. Integers are still compiled to 32-bit, sometimes, but doubles have been standard for quite a while.
Re:WebGPU Shading Language
by mschuetz on Tuesday March 10, 2020 @06:02PM
(#22540274)
I just wish it had support for double and int64. So much great stuff that you can do with 64bit atomic operations that aren't possible with 32 bit atomics.
Re:WebGPU Shading Language
by OceanSunfish on Tuesday March 10, 2020 @06:03PM
(#22540278)
A webkit blogpost from 2018 claims SPIR-V may not be possible to fully secure in a web context. I'm uncertain of the progress or if the original claim was legitimate, but I believe the current experimental implementations of WebGPU do not protect against raw gpu memory access.
A text based language would be easier for beginners (since they wouldn't need to install a separate shader compiler) and would avoid sites that need dynamic shaders having to download and run a shader compiler in the browser.
Using SPIR-V bytecode would benefit from a large amount of work put into an existing standard and an open source compiler ecosystem that many companies are already using.
It looks like a decision has been made to accept a text based language, but one that is defined based on SPIR-V semantics and is easily convertible back and forth from SPIR-V. This seems like a great trade off since if it works out it should have the main advantages of both approaches.
That is more or less the official rationale, but it's pretty clear that the real reason is that Apple is organizationally opposed to SPIR-V (and Khronos generally). This is a tough needle to thread, so I'm glad forward progress is being made.
Khronos sat on their hands for years and only moved after Apple shipped Metal and AMD dumped Mantle in their laps (I'll note that Metal came first). SPIR-V is not the be-all end-all of shader programming. Personally I don't believe we should accept some lowest-common-denominator that puts the future of GPU development in the hands of an organization with the track record Khronos has wrt managing OpenGL. That goes double for the future of WebGPU. However I recognize those are just personal opinions and reasonable people may disagree.
To those offering opinions here: If you've never written a renderer or shader can I suggest you write a toy project using both then see if you still have the same opinion?
Google has spent a lot of effort trying to answer these questions, and they got close, but in the end the text-based solution prevailed. In part, because it was easy to agree on for all parties.
There’s of course also the time for the SPIR-V -> gpu native step. It would be nice if they could just cache that and skip the whole process most of the time.
However, binary form is way more compact for transmission, storage and performance. Almost nobody will use the text form except developers.
That’s what I might expect too, so I was surprised to find out that SPIR-V is usually substantially larger than text based shaders. It also doesn’t seem to compress optimally using standard algorithms. [1]
[1] https://aras-p.info/blog/2016/09/13/Shader-Compression-Some-...
Also if you anticipate the GPU being used as an accelerator, that is all the more reason to use a text based format because it allows for easy code generation.
If you think of AAA games, ML and whatnot, of course. But I doubt anybody will use WebGPU for those, to be honest.
The same with shadertoy, the storage or transmission of a shadertoy shader is never going to be significant compared to all the assets on the page.
The contention was that a binary representation is necessary to save space for storage or transmission. It just isn't.
There's not really a good way of writing WASM without dependencies inside a browser.
WASM by itself doesn't provide new APIs, it's still just a different way to expose the Web platform. So WASM being optional doesn't limit anybody in what they can do. Having WebGPU optional does limit what you can do on the web. We want WebGPU to be available in a wide sense (accessibility, dependencies, portability, everthing).
It seems you speak with "we", as if you were part of the committee? If that is a yes: how can we become part of that committee to amend this mistake? Who has voting rights?
WebGPU community group is open to anyone interested: https://www.w3.org/community/gpu/
Anything you can do with WebGPU you could do in JavaScript, in the same sense that anything you can do with WASM you can do in JavaScript. The only difference is performance.
My enthusiasm for seeing yet another GPU language is very restricted. I simply cannot see the rational arguments in favour of this design. We were so close to having a standard IR for this stuff.
Interesting, what's the successor? I haven't heard of this.
https://webkit.org/blog/9528/webgpu-and-wsl-in-safari/
https://developers.google.com/web/updates/2019/08/get-starte...
https://doc.babylonjs.com/extensions/webgpu
Basically, the Web version of Metal, DirectX12, Vulkan, LibGNM, NVN.
What's wrong with WebGL?
You can see some of that contention here, https://github.com/gpuweb/gpuweb/issues/586 , along with other issues filed.
This is going to be a bumpy ride. I hope it turns out okay.
Sounds like a good thing at first blush, if shaders can be then decompiled to this in debuggers etc.
https://github.com/gpuweb/gpuweb/pull/562
https://github.com/gpuweb/gpuweb/pull/576
Such standards politicking, creation of unneeded entities/standards is basically a "tech sin". They are sinners!
But to generate SPIR-V you still need a high level language. So is this useful for it?
At the same time, SPIR-V semantics is fairly well specified, so we as a group figured that the familiar syntax of HLSL is not as important as the proper GPU behavior and our time specifying it. We've yet to see if it was the right decision - we might as well get stuck with discussing the syntax :)
[0] https://news.ycombinator.com/item?id=22539633
If the motivation is to replace SPIR-V itself, then it's not valid.
I'd say everyone else should take a hard stance on this and show Apple to the door, instead of dancing under their tune.
Releasing a standard that a major member opposes and won't implement is a pointless exercise.
They might use the same medicine.
It's apple that didn't want SPIRV and insisted on something else, preferably text based. Doesn't matter who is doing that something else now, it's done because of Apple... Which I'm not entirely a fan of because I don't think apple's history in WebGL, OpenGL and graphics makes them deserve the leverage they're getting.
I surely hope not the later, let Apple pay performance price for being the root of the problem.
It's not even clear if Chrome or Firefox will accept SPIR-V binary as an extension at this point.
Anyway, conversion to and from SPIR-V is supposed to be straightforward and light. Our (speaking for gfx-rs community) Rust-based shader infrastructure will handle that , and the converter should be easily compilable to wasm (when it's ready).
Anyway x2, most of the time in the whole picture of creating pipelines will be spent in the driver, so whatever parsing performance difference WGSL brings to the table, be it 5% or 10%, doesn't matter, you aren't going to see that in benchmarks because of that other stuff that's going on when you are creating a pipeline.
I hope Mozilla and Google won't cave that way to this Apple's idiotic behavior.
Interesting, that's the first time I hear about it. Do you have some links on the topic? What is the essence of the dispute?
MS: Apple is not comfortable working under Khronos IP framework, because of dispute between Apple Legal & Khronos which is private. Can’t talk about the substance of this dispute. Can’t make any statement for Apple to agree to Khronos IP framework. So
1. https://docs.google.com/document/d/1F6ns6I3zs-2JL_dT9hOkX_25...
Besides, if JS interop were the driving concern, 64-bit doubles would be the default, since that's what JS numbers are.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
BigInt is now available on Firefox and Chrome (with JSC/Safari support in the works). That gives arbitrarily-large integers (with the JIT deciding the best size.
None of the mobile GPU vendors (Apple, ARM Mali, Qualcomm, PVR, BroadCom) support it. You can see that here, where the only vendors supporting shaderFloat64 in Vulkan are desktop GPUs. http://vulkan.gpuinfo.org/listdevicescoverage.php?feature=sh...
Unfortunately it is not exposed in Firefox or Chrome, even if the underlying hardware supports it. I think this is creating a chicken and egg problem - if WebGL were to actually support the capabilities of the underlying hardware, maybe there would be more interest in deploying 64-bit extensions on other platforms like mobile. Even emulated support would be a win, compared to having every developer emulate fp64/i64 themselves in GLSL.
So I am also disappointed in this proposal's failure to mention 64-bit support, even as an extension. At least they're reserving the keywords, I guess.
[1]: https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Scalars
[2]: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_g...
The data types are prefixed with "d", so you have vec4 for float[4], and dvec4 for double[4].
Add that fact that mobile GPUs and some Intel GPUs don't support it in hardware at all, it makes a lot of sense to leave fp64 out of WebGPU.
Edit: and most of the rest are Intel.
It would be interesting to see a graphics API designed to cover a range of 100 000x in performance.
Looks like Nvidia TNT had 2 GB/s of memory bandwidth in 1998 and the high end current ones have ~300-600 GB/s. That's just two orders of magnitude difference. Current fast mobile GPUs seem to get 40 GB/s so that plops to about the middle of the historical PC dGPU range, and is just 1 order of magnitude less than dGPUs.
WebGL mostly serves people with Intel/mobile GPUs, so will probably WebGPU if it is to survive, even though it aims to do better on the high end GPUs as well.
https://webkit.org/blog/8482/web-high-level-shading-language...