shader-slang / slang

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

Properly handle the mismatching "mutating" signature for implementing interfaces #4467

Open jkwak-work opened 4 days ago

jkwak-work commented 4 days ago

Problem description When the interface declares a function with [mutating], the implementation also has to have [mutating]. If the implementation didn't have the keyword, Slang crashes with an internal error.

Goal We should print a proper error for the mistake. Or it should work even when the implementation didn't have the matching [mutating] keyword.

Repro steps The following code can reproduce the issue.

//TEST:SIMPLE:
//TEST:SIMPLE:-DWITH_MUTATING
interface IHitInfo
{
};

interface IClosestHitQuery
{
    [mutating] void traceRay(out IHitInfo hit);
};

struct GeneratePathClosestHitQuery : IClosestHitQuery
{
#if defined(WITH_MUTATING)
    [mutating]
#endif
    void traceRay(out IHitInfo hit)
    {
        hit = {};
    }
};

Note that the modifier out is required to reproduce the issue.

tomas-davidovic commented 4 days ago

Also, note that this only crashes when the out parameter is itself an interface. Normal types (pods and structs) work.