shader-slang / slang

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

Variant of `GatherAlpha()` that takes a `status` argument is not supported #4466

Open chaoticbob opened 4 days ago

chaoticbob commented 4 days ago

This is likely low priority, so filing mostly for documentation purposes right now.

Currently, Slang does not support the variant of GatherAlpha() that takes a status argument:

shader.hlsl(11): error 39999: no overload for 'GatherAlpha' applicable to arguments of type (SamplerState, vector<float,3>, vector<int,2>, uint)
    uint4 e = t2u4.GatherAlpha(gSampler, location, int2(1, 2), status);
                              ^
hlsl.meta.slang(2329): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3, int2, int2, int2, int2) -> uint4
hlsl.meta.slang(2315): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3, int2) -> uint4
hlsl.meta.slang(2301): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3) -> uint4
shader.hlsl(12): error 39999: no overload for 'GatherAlpha' applicable to arguments of type (SamplerState, vector<float,3>, vector<int,2>, vector<int,2>, vector<int,2>, vector<int,2>, uint)
    uint4 f = t2u4.GatherAlpha(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
                              ^
hlsl.meta.slang(2329): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3, int2, int2, int2, int2) -> uint4
hlsl.meta.slang(2315): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3, int2) -> uint4
hlsl.meta.slang(2301): note 39999: candidate: func __TextureImpl<vector<T,N>, Shape, isArray, 0, sampleCount, 0, isShadow, 0, format>.GatherAlpha(SamplerState, float3) -> uint4

CMD

slangc.exe -target spirv -lang slang -D__spirv__ -emit-spirv-directly -profile ps_6_0 -entry main shader.hlsl

Shader

SamplerState gSampler : register(s5);

Texture2DArray<float4>  t2f4       : register(t1);
Texture2DArray<uint4>   t2u4       : register(t2);
TextureCubeArray<uint4> tCubeArray : register(t3);

float4 main(float3 location: A) : SV_Target {
    uint status;
    uint4 e = t2u4.GatherAlpha(gSampler, location, int2(1, 2), status);
    uint4 f = t2u4.GatherAlpha(gSampler, location, int2(1, 2), int2(3, 4), int2(5, 6), int2(7, 8), status);
    uint4 g = tCubeArray.GatherAlpha(gSampler, float4(1.5, 1.5, 1.5, 1.5), status);
    return (float4)(e + f + g);
}