shader-slang / slang

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

Namespace Functions not supported as EntryPoint #2144

Open taxmancw opened 2 years ago

taxmancw commented 2 years ago
struct PSInput
{
    float4 color : COLOR;
};

namespace Pixel
{
    float4 Main(PSInput input) : SV_TARGET
    {
        return input.color;
    }    
}

In the following example, specifying Pixel::Main as the entry point fails to compile in Slang, but will work in HLSL compilers FXC and DXC.

tangent-vector commented 2 years ago

Thanks. This is definitely worth fixing.

Note for whatever contributor picks this up: our intention is to also support entry point functions as members of struct types, so we should try to ensure that when we write the code to handle the namespace case in this issue we also write code that is looking toward that option down the road.

tangent-vector commented 2 years ago

I am putting together a test case for this feature, but I cannot seem to get dxc (when driven via the dxcompiler.dll API) to recognize an entry point like the above. For a trivial compute shader, I get as output:

error: missing entry point definition

Can somebody confirm the expected versions of dxc for which entry points in namespaces work?

taxmancw commented 2 years ago

It appears that DXC is actually also lacking support for it and has yet to be addressed. https://github.com/Microsoft/DirectXShaderCompiler/issues/1854

natduca commented 7 months ago

Q3 language hardening