Hacker News new | ask | show | jobs
by pjmlp 890 days ago
I don't see a point of that versus middleware engines, with much better tooling.

WebGPU/WebGL are like JavaScript, something that we have to put up with, because on the browser there is no other alternative.

No need to constrain ourselves to the browser limitations when there are other options.

3 comments

Don’t be fooled by “web” in the name. Just like WebAssembly is/will be a better JVM, WebGPU is already posed to be a better OpenGL/Vulkan. It is a full graphics API unconstrained by browser implementations, and available without a browser runtime.
I am curious, in what ways is WebGPU better than Vulkan or Metal? From my point of view, WebGPU going back to an interpreted shading language like OpenGL makes it conceptually closer to JavaScript than WebAssembly.
HLSL has in practice become the shader language for Vulkan, and Metal has always had a high-level shading language. The GPU market is simply too heterogeneous for a low-level ISA like SPIR-V to be applicable and performant across all architectures. A modern GPU driver effectively has to "decompile" SPIR-V binaries, then recompile it to the actual vendor-specific architecture used on the installed GPU, and perform both high-level and low-level optimizations. Standardizing on a single high level shading language, but one purposefully designed to be cross-platform, is actually the simpler architecture here.
I wrote a big visualization application with WebGPU and I'm happy with the choice. It's much cleaner than OpenGL, without as much complexity as Vulkan or Metal. It runs on Mac & Linux, and I got a demo version working in the browser with emscripten fairly easily. It doesn't have the trouble with OpenGL version compatibility that used to make supporting multiple platforms a hassle.

I'm not sure what's 'interpreted' about it. On Mac, the wgpu-native driver transcodes to the Metal shading language and it gets compiled.

I gave up on Vulkan simply because it's too overengineered and cumbersome. WebGPU, on the other hand, is relatively easy to use, even though it is build on many of the same concepts.
WebGPU IS basically Metal, but cross platform. When the W3C decided to standardize a new graphics API, Apple submitted a proposal that was basically Metal with a name change. That proposal became the basis of WebGPU, though like any committee standard it has undergone multiple revisions since then.

Metal itself was basically Apple looking at Vulkan and saying “Lol, no way in hell. That’s a stinking mess of complexity.” Then they went off and made a simpler, less boilerplate, easier to code but just as performant and powerful API for Apple platforms. Now WebGPU makes all those improvements available everywhere.

And ignore the Web prefix: WebGPU is a lower level API, like DX12, Vulkan or Metal. It just came out of the W3C, hence the name. Unfortunately the name makes people think that it is a JavaScript browser extension or something, which is is not. You can call it from a browser, yes, and the API is designed to enable sandboxed instances for that purpose, but that’s a higher level integration, just like how WebGL exposes OpenGL ES.

In fact maybe that’s a better way to explain it. Until now if you wanted 3D in a browser you had to use WebGL which gave you a OpenGL ES compatible API. Except OpenGL is ancient and GLES doesn’t support vendor extensions, so this was a really shitty situation. W3C decided “Let’s make a new low level graphics API to replace OpenGL ES, and a new JavaScript browser extension to expose that API [replacing WebGL]” and they decided to confusingly call at various times both things, and the whole stack together when integrated with a browser “WebGPU.”

However most of the excitement and work surrounding WebGPU right now is around Rust and C++ frameworks that are using WebGPU as a platform and device independent middleware framework, since the standard implementations will performantly transform WebGPU calls into Metal, Vulkan, or DX12 system calls based on what the end user system supports, making it an excellent middleware that is really easy to target. So really, WebGL is a replacement for OpenGL in a way that Vulkan was not.

Vulkan is too hard and metal is only for mac.
It isn't WebGPU any longer if it is incompatible with browsers.
A single code base for both native & web? Not having to write Javascript on the web?
Exactly this, along with a lot of the "smoothing-out" done by the webgpu spec which provides a clear and open abstraction target.
Minimum common set of features from 2015 hardware.
Only if you enjoy coding to 2015 hardware specifications in 2024, leaving the rest of the hardware out.
I think you are confusing WebGPU with WebGL?

WebGPU standard process only started in 2021, and is still undergoing revisions.

OP is right. WebGPU is targeted towards the lowest common denominator, which is fairly old mobile phones. It therefore doesn't support modern features and is basically an outdated graphics API by design.
Care to give an example? From my viewpoint as a WebGPU user, we consistently get access to new GPU features with every refresh. E.g: https://developer.chrome.com/blog/webgpu-io2023

You just have to set limits correctly when you initialize a GPU instance in order to have access to the new features.

Mesh shaders, raytracing, DirectStorage, GPU work graphs, C++ features on shading languages, some of the post 2015 features that aren't coming to WebGPU any time soon.
Apart from the examples given by the other user: 64 bit integers and their atomics which are the bread and butter of efficient software rasterizers such as Nanite, or for point clouds which can be rendered multiple times faster with 64 bit atomics compared to using the "point-list" primitive; subgroup operations; bindless; sparse buffers; printf; timestamps inside shaders; async memcpy and copy without the necessity for an intermediate copy buffer and so much more. One of the worst is that they're adding limitations of all languages, but not the workarounds that may exist in them. Like WebGPU actively prohibits buffer aliasing or mixing atomic and non-atomic access to memory because of Apple's Metal Shading Language, but Metal supports it via workarounds! I mean... seriously? That actually makes WebGPU even worse than the lowest common denominator.

One of the turning points for the worse was the introduction of WGSL. Before WGSL, you could do lots of stuff with spirv shaders because they weren't artifically limited. But with WGSL, they went all in on turning WebGPU into a toy-language that only supports whatever last decades mobile phones support. I was really hopeful for WebGPU because UX-wise, it is so much better than anything else. Far better than Vulkan or OpenGL. But feature-wise, WebGPU so limited that I had to go back to desktop OpenGL.

In one way WebGPU really has become a true successor to WebGL though - it is a graphics API that is outdated on arrival.

I dunno, writing GPU code that works across Mac/Win/Lin/iOS/droid isn’t easy to deploy.
Unity, Unreal, Open3D, Ogre 3D, Godot, Defold, Stride,... look all pretty easy to me, with access to hardware features not available in WebGPU.
I’m not running unity to get some fast matrix multiplication, lol.