Live data from Hacker News

The Slang Shading Language

shader-slang.com

31–40 of 50 posts

Re: The Slang Shading Language

#31
post #8

The design of generics in this one seems rather well balanced in simplicity vs power. The part about interface-typed values [1] is interesting. They do dynamic dispatch as a fallback when the function is too polymorphic to be be specialized. In Rust terms it's as if it picks between `dyn` and `impl` automatically. It looks convenient, but also a bit of a non-obvious performance pitfall. [1] https://shader-slang.com/s…

It seems like the type checker could call out polymorphic functions both when compiling and even highlighting them in the editor when checking for type errors.

Re: The Slang Shading Language

#32

Will Slang support compute shaders too, or is it just for graphics.

It does! Both platform-specific compute shaders as well as cross-compilation to CUDA. The authors even provide some basic PyTorch bindings to help use existing shader code for gradient computation and backpropagation in ML and differentiable programming of graphics-adjacent tasks: https://github.com/shader-slang/slang-torch (Disclaimer: this is the work of my colleagues, and I helped test-drive differentiable Slang and wrote one of the example applications/use-cases)

Re: The Slang Shading Language

#33

I hope this becomes the standard way of writing shaders across all platforms. There is no compelling reason for having to use WGSL, HLSL, GLSL or Metal C++. Having one single feature-complete language is a huge QoL improvement.

Nobody is using all these languages at the same time, anyone who targets all these platforms already has some mechanism to turn HLSL or GLSL (or whatever) into what the target platform needs. That's why Slang will have difficulty finding adoption, it's the N+1th solution to a problem that already has been solved N times.

> anyone who targets all these platforms already has some mechanism to turn HLSL or GLSL (or whatever) into what the target platform needs

Slang provides a standard and open source solution that's better and more featureful than those custom solutions.

Re: The Slang Shading Language

#34

I hope this becomes the standard way of writing shaders across all platforms. There is no compelling reason for having to use WGSL, HLSL, GLSL or Metal C++. Having one single feature-complete language is a huge QoL improvement.

What is missing from GLSL?

It depends on your needs, but there's a reason why HLSL took over GLSL. HLSL provides enums, templates, namespaces and many other QoL improvements that GLSL didn't get.

I for example really welcome Slang's support for automatic differentiation.

Re: The Slang Shading Language

#35
One unique and new feature of Slang that sets it apart from existing shading languages is support for differentiation and gradient computation/propagation - while still cross-compiling generated forward and backward passes to other, platform-specific shading languages. Before, the only way to backpropagate through shader code (such as material BRDF or lighting computation) was to either manually differentiate every function and chain them together, or rewrite it in another language or framework - such as PyTorch or a specialized language/framework like as Dr.Jit, and keeping both versions in sync after any changes. Game developers typically don't use those, programming models are different (SIMT kernels vs array computations), it's a maintenance headache, and it was a significant blocker for a wider adoption of data-driven techniques and ML in existing renderers or game engines.

Re: The Slang Shading Language

#36

I hope this becomes the standard way of writing shaders across all platforms. There is no compelling reason for having to use WGSL, HLSL, GLSL or Metal C++. Having one single feature-complete language is a huge QoL improvement.

Nobody is using all these languages at the same time, anyone who targets all these platforms already has some mechanism to turn HLSL or GLSL (or whatever) into what the target platform needs. That's why Slang will have difficulty finding adoption, it's the N+1th solution to a problem that already has been solved N times.

I see your point, but one issue is that you can't go from HLSL or GLSL to WGSL for compute work, as the way atomics are typed is incompatible[1]. That's a primary reason we (currently) use WGSL, because going from that to legacy shader languages does work. But then you have all the limitations of WGSL.

Slang had to make a change to its type system[2] to make this work. But they did it, and as a result Slang is appealing as an "apex" language - you can translate from that to anything, and also get advanced features lacking in WebGPU.

[1]: https://github.com/gpuweb/gpuweb/issues/2377

[2]: https://github.com/shader-slang/slang/issues/5084

Re: The Slang Shading Language

#37
post #7
post #4

I've been very impressed by Slang as an open source project. The development team is quick to respond to issues and review pull requests. It's clear from their repository and their presentations that they take Slang seriously as a user-facing project, not a research demo.

Several commercial products are already using Slang, it has moved beyond research demo for quite some time now. The main difference, with something like Cg, is that now it isn't NVidia only.

I have known about slang for some time but hadn’t heard about these commercial products.

Can you elaborate?

Re: The Slang Shading Language

#39

I hope this becomes the standard way of writing shaders across all platforms. There is no compelling reason for having to use WGSL, HLSL, GLSL or Metal C++. Having one single feature-complete language is a huge QoL improvement.

Nobody is using all these languages at the same time, anyone who targets all these platforms already has some mechanism to turn HLSL or GLSL (or whatever) into what the target platform needs. That's why Slang will have difficulty finding adoption, it's the N+1th solution to a problem that already has been solved N times.

RetroArch uses all of them. HLSL, GLSL, Vulkan, Slang, Cg as well as proprietary shader formats used on consoles, as some platforms only support specific formats, so they often convert between all of them to offer as many shaders as possible across all combinations of platforms.

But one of their big contributors also worked on Vulkan and Slang/SPIR-V itself if I recall correctly (and works at ARM on GPU drivers), so there's that.

Re: The Slang Shading Language

#40
post #7

Earlier quoted context omitted.

Several commercial products are already using Slang, it has moved beyond research demo for quite some time now. The main difference, with something like Cg, is that now it isn't NVidia only.

I have known about slang for some time but hadn’t heard about these commercial products. Can you elaborate?

From Vulkanised 2024,

https://vulkan.org/user/pages/09.events/vulkanised-2024/vulk...

Omniverse, Portal RTX, RTX Remix, Source 2 shading infrastructure,

Post reply on HN