shader-slang / slang

Making it easier to work with shaders
MIT License
2.06k stars 177 forks source link

Change error unknown Attribute `RootSignature` to warning instead #4367

Closed chaoticbob closed 3 months ago

chaoticbob commented 3 months ago

Shader source shared across multiple platforms will sometimes make use of [RootSignature()], currently Slang throws and error if encounters the attribute RootSignature.

To ease on ramping, can Slang issue a warning instead of an error when it encounters the attribute RootSignature?

#define RootSigClearUAV "RootFlags(0), "    \
    "RootConstants(num32BitConstants=8, b0)," \
    "DescriptorTable(UAV(u0))"

RWTexture1D<float4> tex : register(u0);

struct InputData
{
    float4 clearValue;
    uint   width;
    uint   height;
    uint   depthOrArraySize;
};

cbuffer InBuffer : register(b0)
{
    InputData data;
}

[numthreads(64, 1, 1)]
[RootSignature(RootSigClearUAV)]
void csmain(uint threadId : SV_DispatchThreadID)
{
    uint pos = clamp(threadId, 0, data.width - 1);
    tex[pos] = data.clearValue;
}