News for hackers. Stuff that matters.
Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @05:01AM (#35465966)
This is HUGE news. Webgpu solves the incentives problem where all actors tries to lock you in to their graphics/compute ecosystem by abstracting over them. It's already the best way to code cross-platform graphics outside the browser. This release in Chrome ought to bring lots more developer mindshare to it, which is an awesome thing.
Re:Chrome Ships WebGPU by illiarian on Thursday April 06, 2023 @05:23AM (#35466113)
> This is HUGE news. Webgpu solves the incentives problem where all actors tries to lock you in to their graphics/compute ecosystem by abstracting over them.

Instead we have a third graphics standard (after canvas and WebGL) fully incompatible with the previous two that does exactly that: abstracts the OS graphics stack in a new layer

Re:Chrome Ships WebGPU by adrian17 on Thursday April 06, 2023 @05:38AM (#35466211)
Further, in some ways it's the "lowest common denominator" (so that it can be easily implemented on top of each "underlying" graphics API), with union of all their downsides and only intersection of upsides.
Re:Chrome Ships WebGPU by flohofwoe on Thursday April 06, 2023 @06:02AM (#35466362)
WebGPU brings some important improvements that are simply impossible to implement with the WebGL programming model (such as moving all the expensive dynamic state validation from the draw loop into the initialization phase).

It's not perfect mind you (e.g. baked BindGroups may be a bit too 'rigid'), but it's still a massive improvement over WebGL in terms of reduced CPU overhead.

Re:Chrome Ships WebGPU by dilawar on Thursday April 06, 2023 @08:43AM (#35467589)
obligatory xkcd: https://xkcd.com/927/
Re:Chrome Ships WebGPU by gostsamo on Thursday April 06, 2023 @05:16AM (#35466076)
or it will be yet another standard
Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @05:23AM (#35466120)
Not really. I don't see how any of the vendors could break it without being extremely overt about it. And it has no direct competition. Nothing else runs on any OS and any GPU, except WebGL, which is abandoned.
Re:Chrome Ships WebGPU by illiarian on Thursday April 06, 2023 @05:25AM (#35466134)
> I don't see how any of the vendors could break it without being extremely overt about it.

> except WebGL, which is abandoned.

So it can be abandoned

Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @05:35AM (#35466199)
It becoming a stale standard is maybe the biggest threat, yes. It has the issue all standards have since several actors have to play along, except this time it isn't Nvidia, Apple, and AMD, but Wgpu/Mozilla and Google. Their incentives are hopefully better aligned with users than those of the hardware vendors.

I suspect WebGL was different, since it was based on the old OpenGL/DX9 way of doing things, so a clean break was desireable. But I honestly am not that knowledgeable in neither graphics programming nor WebGL history, so take that with several grains of salt.

Re:Chrome Ships WebGPU by pjmlp on Thursday April 06, 2023 @05:46AM (#35466269)
WebGL was based on OpenGL ES 2.0 and a subset of OpenGL ES 3.0.

Google refused to support WebGL compute based on OpenGL ES 3.0 compute shaders, citing WebGPU alternative, and there are still quite a few capabilites from OpenGL ES 3.2 missing from WebGL.

Some of which still not available in WebGPU 1.0.

Re:Chrome Ships WebGPU by whitehexagon on Friday April 07, 2023 @09:29AM (#35481375)
Pretty impressed with WebGL2, and it is already on most platforms, so I hope it wont be pushed aside by this. I assumed WebGPU was going to be more about a Web based OpenCL implementation, is OpenCL also being pushed aside by this then? and wasnt there a plan to do some compute with WebGL? I cant keep up! I hope this myriad of new Chrome APIs being pushed slows down enough for some new browser vendors to enter the market. Or is this just a push for a new 'native' browser experience single horse race...
Re:Chrome Ships WebGPU by kllrnohj on Thursday April 06, 2023 @10:19AM (#35468634)
Vulkan & GLES are both the obvious competition here, I don't know why you seem to be ignoring them?
Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @04:06PM (#35473644)
Vulkan doesn't run on Apple platforms. And Apple refuses to upgrade their OpenGL drivers. So no, they don't count. Then there are the consoles, which also have their own APIs. Expecting all vendors to implement a common API is a fool's errand, and we should stop trying. The vendors don't want this, and we can't force them. Any common GPU API must be an abstraction over vendor-specific ones.
Re:Chrome Ships WebGPU by kllrnohj on Thursday April 06, 2023 @06:42PM (#35475512)
MoltenVK exists and runs Vulkan on Apple devices perfectly fine. Almost certainly better than WebGPU does even. Vulkan is already a common API both in theory and in practice.

It's not a nice API, but it is common and vendor neutral all the same. A lot moreso than WebGPU is, even, since Khronos has a much more diverse set of inputs than the web does. See eg all the complaints about Chrome dominating the web discussion, and even beyond that you only really need 3 companies on board. Khronos has significantly more at the table than that.

Re:Chrome Ships WebGPU by pl90087 on Thursday April 06, 2023 @05:18AM (#35466085)
Re:Chrome Ships WebGPU by pjmlp on Thursday April 06, 2023 @05:44AM (#35466257)
There are lots of ways to write code cross-platform graphics outside the browser, it has been available for decades, it is called middleware.

WebGPU outside of the browser not only suffers the pain of being yet another incompatible shading language, it is also offers the additional possibility of having code incompatible with browsers WebGPU support, due to the use of extensions not available on the browsers.

Re:Chrome Ships WebGPU by flohofwoe on Thursday April 06, 2023 @05:57AM (#35466337)
AFAIK the WebGPU implementations outside the browser can all load SPIRV directly, no need to translate to WGSL first.
Re:Chrome Ships WebGPU by pjmlp on Thursday April 06, 2023 @06:04AM (#35466369)
Yes, and that is one of the reasons why I wrote it is also offers the additional possibility of having code incompatible with browsers WebGPU support.
Re:Chrome Ships WebGPU by flohofwoe on Thursday April 06, 2023 @06:07AM (#35466385)
These differences are smaller than the differences between desktop GL and WebGL though. It's just another option in the low-level vs high-level 3D API zoo. As far as wrapper APIs go, the native WebGPU implementation libraries are a pretty good option, because being also used in browsers there's a ton of testing and driver bug workarounds going into them which other 3D API wrapper projects simply can't afford to do.
Re:Chrome Ships WebGPU by pjmlp on Thursday April 06, 2023 @06:10AM (#35466404)
Not at all.

First of all, if one depends on SPIR being present, then a SPIR to WGSL compiler needs to be present when deploying to the Web part of WebGPU.

Secondly, it will be yet another extension spaghetti that plagues any API that Khronos has some relation to.

Re:Chrome Ships WebGPU by flohofwoe on Thursday April 06, 2023 @06:19AM (#35466457)
It already made sense to have a SPIRV- and SPIRVCross-based shader pipeline in cross-platform engines with WebGL support though (because you'd want to author shaders in one shading language only, and then translate them to various target languages, like some desktop GLSL version, then separate versions for GLES2/WebGL and GLES3/WebGL2, and finally HLSL and MSL, WGSL is just another output option in such an asset pipeline).
Re:Chrome Ships WebGPU by pjmlp on Thursday April 06, 2023 @06:27AM (#35466490)
And we all know how well it works when features don't map across languages, WebGPU meeting minutes is full of such examples, hence why threejs is adopting a graphical node editor for easing the transition between GLSL and WGSL.
Re:Chrome Ships WebGPU by mike_hearn on Thursday April 06, 2023 @06:09AM (#35466398)
"Webgpu solves the incentives problem where all actors tries to lock you in"

Or flipped around, it creates an incentive problem where none of the vendors see much benefit in doing R&D anymore, because browsers aren't content to merely abstract irrelevant differences, they also refuse to support vendor extensions except for their own. No point in adding a cool new feature to the GPU if Chrome/Safari insists on blocking it until your competitors all have it too.

Luckily the GPU industry is driven by video games and nowadays AI, industries that don't write code using the web stack. So they'll be alright. Still, that same incentives problem exists in other areas of computing that sit underneath the browser (CPUs, hardware extensions, operating systems, filesystems, etc). Abstractions don't have to erase all the differences in what they abstract, but people who create them often do so anyway.

Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @06:26AM (#35466488)
Good and valid point. Effort will naturally focus on the lowest common denominator. Any new features would have to be implemented in software in the WebGPU layer for targets without API support. That's probably going to slow development of new extensions.

However, I think what GPU programming needs at the moment is better ergonomics, and code portability is a step in the right direction, at least. Currently it's quite a bit more annoying than CPU programming.

Re:Chrome Ships WebGPU by mike_hearn on Thursday April 06, 2023 @06:29AM (#35466506)
Yeah, but that's because performance always takes priority. The Vulkan/DX12/Metal APIs are lower level and much more tedious than OpenGL and shader based OpenGL was itself a step backwards in usability from the fixed function pipeline (when doing equivalent tasks). So the trend has been towards more generality and performance at the cost of usability for a long time in graphics APIs. Prefixing it with "Web" won't change that. I'm not saying that's a bad trend - the vendors take the perspective that people who need usability are using game engines anyway so "easy but low level" like classic GL is a need whose time has passed. There's probably a lot of truth to that view.
Re:Chrome Ships WebGPU by tormeh on Thursday April 06, 2023 @06:52AM (#35466655)
Which is fine, IMO, as long as there are user-friendly abstractions on top of those foundations. I'd "just" like to write high-level code that runs on GPUs without having to worry about vendor/OS differences (yay, WebGPU) or writing boilerplate (nay, WebGPU). Currently it's all a bit too annoying for normal programmers to bother with. Every month there's a new programming language for CPUs that intends to make programming easier. I'd like this state of things, but for GPUs.
Re:Chrome Ships WebGPU by fulafel on Thursday April 06, 2023 @11:38AM (#35469874)
It doesn't pay off for most apps to run on GPUs because of the fragmentation, bad dev experience, sad programming language situation, proprietary buggy sw stacks and so on. Reining in the cambrian explosion to let applications actually use GPUs would be a good tradeoff.

(But of course like you say this doesn't detract from the native code apps that want to debug, support, bug-workaround, perf-specialcase their app on N operating systems x M GPU hardware archs x Z GPU APIs, x Y historical generations thereof)

Re:Chrome Ships WebGPU by adam_arthur on Thursday April 06, 2023 @02:27PM (#35472381)
You could say the same about working off a common html, browser, language spec. There are tradeoffs, but industry consensus hasn't really stifled innovation in any meaningful way.

Why can't a common graphics API evolve through well researched and heavily scrutinized proposals? The amount of societal loss of efficiency in having competing specs that do the same thing in slightly different ways, but require immense effort to bridge between is truly vast.

The incentive to innovate comes from limitations with the current spec. That doesn't change just because there's consensus on a common base spec

Re:Chrome Ships WebGPU by mike_hearn on Thursday April 06, 2023 @04:48PM (#35474191)
There are tradeoffs, but industry consensus hasn't really stifled innovation in a meaningful way.

Stifled innovation in what context? I wouldn't describe the web stack as an industry consensus given the rejection of it (for apps) by mobile devs, mobile users, video game devs, VR devs and so on. If you mean within the web stack, then, well, there have been plenty of proposals that died in the crib because they couldn't get consensus for rather obscure reasons that are hard to understand from the outside. Certainly, there were innovations in the earlier days of the web when it was more open that have never been replicated, for example, Flash's timeline based animation designer died and nothing really replaced it.

Fundamentally we can't really know what cool things might have existed in a different world where our tech stack is more open to extensions and forking.

Why can't a common graphics API evolve through well researched and heavily scrutinized proposals?

Why can't everything be done that way? It's been tried and results are a tragedy of the commons. These ideas don't originate in the web world. The incentive to develop the tech isn't actually limits in web specs, that's a decade+ after the innovation happens. What we see is that the web stuff is derivative and downstream from the big players. WebGPU traces its history through Vulkan to Metal/D3D12 and from there to AMD's Mantle, where it all started (afaik). So this stuff really starts as you'd expect, with some risk taking by a GPU designer looking for competitive advantage, then the proprietary OS design teams pick it up and start to abstract the GPU vendors, and then Khronos/Linux/Android realizes that OpenGL is going to become obsolete so they'd better have an answer to it, and then finally the HTML5 people decide the same for WebGL and start work on making a sandboxed version of Vulkan (sorta).

N.B. what made Mantle possible is that Windows is a relatively open and stable environment for driver developers. Ditto for CUDA. They can expose new hardware caps via vendor-specific APIs and Microsoft don't care/encourage it. That means there's value in coming up with a radical new way to accelerate driver performance. In contrast, Apple write their own drivers / APIs, Linux doesn't want proprietary drivers, ChromeOS doesn't even have any notion of an installable vendor driver model at all.

Re:Chrome Ships WebGPU by hot_gril on Friday April 07, 2023 @08:14PM (#35488919)
That's fine. They can make the special features for native apps (aka video games) while common things on the web get GPU acceleration. Right now the GPU compatibility situation is pretty bad for the average user despite most of the feature sets being essentially the same.
Re:Chrome Ships WebGPU by singularity2001 on Thursday April 06, 2023 @06:54AM (#35466666)

     the best way to code cross-platform graphics outside the browser. 
so WebGPU is a bit like WebAssembly which might really shine outside the Web (on the Edge, as universal bytecode format, for plugins …)
Re:Chrome Ships WebGPU by kllrnohj on Thursday April 06, 2023 @10:17AM (#35468605)
Except unlike WebAssembly this one is actually useful. WASM enters a domain full of existing universal bytecodes that all failed to become truly universal because the actual assembly is never the hard part to get portable, it's the API surface. Which WASM doesn't even pretend to attempt to handle, unlike a Java or C# which ship pretty fat bundled libraries to abstract most OS differences.

Meanwhile on the GPU front you don't have much in the way of large, good middlewares to abstract away the underlying API. OpenGL used to be OK at this, but now neither platforms nor Khronos wants to touch it. Vulkan is "portable" but it's like writing assembly by hand, it's ludicrously complicated. WebGPU fills the role of essentially just being GLES 4.0. It won't be fast, it won't be powerful, but it doesn't actually need to for the long tail of things that just want to leverage a GPU for some small workloads.

Re:Chrome Ships WebGPU by mschuetz on Thursday April 06, 2023 @10:09AM (#35468507)
Unfortunately WebGPU is also an essentially a 5 year old mobile phone graphics API, which means for most desktop features younger than 10 years, you'll still need DirectX, Vulkan, or Metal.
Re:Chrome Ships WebGPU by hinell on Saturday April 08, 2023 @06:20AM (#35492039)
Still, this comes at cost of new complexity. They just createa and abstraction over different operating system APIs. This isn't something cool really. Now they trying to obsolete Webgl. What a joke..