News for hackers. Stuff that matters.
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.