News for hackers. Stuff that matters.
Re:WebGPU Shading Language by jfkebwjsbx on Tuesday March 10, 2020 @01:47PM (#22537658)
Indeed. A text-based language makes no sense in 2020. WASM already took the approach of going binary-first.
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 antoineMoPa on Tuesday March 10, 2020 @05:06PM (#22539687)
As an example, ShaderToy (and ShaderGif which I built) compile shaders directly in the browser.
Re:WebGPU Shading Language by jfkebwjsbx on Tuesday March 10, 2020 @08:30PM (#22541626)
As they have already told you, shaders being in binary or text form is orthogonal to making a tool like ShaderToy.

However, binary form is way more compact for transmission, storage and performance. Almost nobody will use the text form except developers.

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]

[1] https://aras-p.info/blog/2016/09/13/Shader-Compression-Some-...

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 jacobolus on Wednesday March 11, 2020 @08:00AM (#22545025)
That’s maybe true for current 3D graphics heavy projects, but is not necessarily true for any arbitrary future use of GPU compute.
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 mantap on Wednesday March 11, 2020 @05:42PM (#22551080)
50MB of textures is a lot compared to shader source code size, which will be in the kilobytes for such a small project.

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.

Re:WebGPU Shading Language by rubber_duck on Wednesday March 11, 2020 @08:12AM (#22545088)
I'm sure there will be JS libraries that can compile them in the browser - a minor inconvenience for those apps.
Re:WebGPU Shading Language by fulafel on Wednesday March 11, 2020 @02:52PM (#22549014)
Why does it require a compiler stack?
Re:WebGPU Shading Language by imtringued on Thursday March 12, 2020 @10:46AM (#22557390)
If you want to use React with JSX then you must add babel to your project.
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 kvark on Tuesday March 10, 2020 @10:46PM (#22542473)
How are you suggesting to write shaders in the browser if they are expected to be in a binary form?

WebGPU community group is open to anyone interested: https://www.w3.org/community/gpu/

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.