shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
Other
3.05k stars 211 forks source link

Shader attributes ignored? #5541

Open Ollhax opened 2 weeks ago

Ollhax commented 2 weeks ago

I have a slang file containing two entry points for the vertex and fragment shaders:

[shader("vertex")]
VertexOutput vertexMain(VertexInput vertexInput)
{
    ...
}

[shader("fragment")]
float4 fragmentMain(CoarseVertex vertex: CoarseVertex) : SV_Target
{
    ...
}

When I run slangc shader.slang -target glsl -stage vertex (or via -o out.vert) I expect it to be able to find the [shader("vertex")] and figure out that vertexMain is the entry point it needs, but instead I get an error:

shader.slang(3): error 38000: no function found matching entry point name 'main'

I can rename vertexMain to "main" and it'll work, but it doesn't work if I rename both vertexMain and fragmentMain to "main".

csyonghe commented 2 weeks ago

The commandline tool doesn't respect the predefined entrypoint attributes, but the compilation API can correctly identify them.

If you are using the slangc tool, you need to explicitly specify which entrypoint to compile:

slangc shader.slang -target glsl -entry vertexMain -stage vertex
Ollhax commented 1 week ago

Alright, thanks for the clarification. I can work around it, but it would be nice to have support for entrypoint attributes in the commandline tool. It's easy to trip on, if nothing else.