shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

support for opengl #4257

Closed Raildex closed 1 month ago

Raildex commented 1 month ago

I want to generate a SPIRV file that can be used with OpenGLs glShaderBinary and glSpecializeShader.

OpenGL's spec only says a vendor needs to support SPIRV 1.0. But for whatever reason - and i think that's the issue - slang only emits SPIRV 1.5

no matter which -capability (btw, how am i supposed to add multiple capabilities? -capability <cap> -capability <cap2> or -capability <cap>+<cap2> or -capability <cap> <cap2>? the docs aren't clear about this) I use, it seems to spit out SPIRV 1.5

csyonghe commented 1 month ago

With PR #4254, we now support generating spirv 1.3 to 1.6 with the -profile spirv_1_x option. Currently you can still specify -profile spirv_1_0 but this is not officially supported in our direct to spirv backend.

To produce spirv 1.0 to 1.2, we recommend using the glsl backend, by specifying the -emit-spirv-via-glsl option. When this option is specified, Slang will generate glsl first, then pass that glsl to glslang to produce final spirv.

Raildex commented 1 month ago

Thanks for the quick answer. Can I use multiple entry points, i.e. [shader("vertex")] and [shader("pixel")] in a single .slang file, compile it with -emit-spirv-via-glsl and then use glSpecializeShader to select the entry points?

csyonghe commented 1 month ago

The glsl path cannot allow multiple entry points, unfortunately. You can still try to use -profile spirv_1_0 without -emit-spirv-via-glsl and see if things are working. We can fix any issues you run into.

csyonghe commented 1 month ago

Closing this issue now. Please let us know if you run into any detailed issues when using -profile spirv_1_0 and we can fix them even though we don't officially support it yet.