slang icon indicating copy to clipboard operation
slang copied to clipboard

Compiling Slang to other shading languages (Metal, ESSL)

Open jarble opened this issue 3 years ago • 2 comments

Is the Slang compiler able to generate Metal or ESSL shaders instead of GLSL?

If the Slang compiler doesn't already have this feature, then it could probably use SPIRV-Cross or ShaderConductor to generate Metal and ESSL shaders.

jarble avatar Sep 19 '20 21:09 jarble

Support for more targets is always desirable, and we’d welcome pull requests that work toward support for the Metal shading language ESSL, etc.

The existing GLSL output from Slang can sometimes be used on OpenGL, but we currently don’t have logic to avoid/detect Vulkan-specific features. A back-end to support the OpenGL ES shading language (and/of WebGL) would probably need to start with making our GLSL output more compatible with desktop OpenGL.

Using another stage of translation on the output from Slang (as you describe) could be useful as a short-term solution for users who need support for platforms other than the current ones. The risk on that path is that the output for Metal, ESSL, etc. becomes limited to the “lowest common denominator” features of what is exposed in SPIR-V.

In the long run we believe that a dedicated Metal back-end will be worthwhile because then it will be possible for Slang to expose and take advantage of features that are only available on that API.

Our goal with Slang is that it allows for portable code when you want it, but also supports writing code that uses API-specific features when you need to.

tangent-vector avatar Sep 20 '20 01:09 tangent-vector

Lets have a conversatiton about this in Q2 --- theres a priority thing but keeping this so we have the conversation at the right time

natduca avatar Dec 01 '23 19:12 natduca