shader-slang / slang

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

SPIR-V: Error message for `WaveMultiPrefix` functions is not easy to understand #4443

Open chaoticbob opened 1 week ago

chaoticbob commented 1 week ago

When compiling this shader:

StructuredBuffer<uint4> g_mask;

float4 main(uint4 input0 : ATTR0) : SV_Target {
    uint4 mask = g_mask[0];

    uint4 res1 = WaveMultiPrefixProduct(input0, mask);
    uint4 res2 = WaveMultiPrefixSum(input0, mask);
    uint4 res3 = WaveMultiPrefixBitAnd(input0, mask);
    uint4 res4 = WaveMultiPrefixBitOr(input0, mask);
    uint4 res5 = WaveMultiPrefixBitXor(input0, mask);
    return res1 + res2 + res3 + res4 + res5;
}

CMD

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

I get this result:

shader.hlsl(11): error 36107: entrypoint 'main' requires capability 'textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + vertex | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + fragment | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + compute | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + hull | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + domain | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + geometry | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + raygen | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + intersection | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + anyhit | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + closesthit | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + miss | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + mesh | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + amplification | textualTarget + cuda + cuda_sm_1_0 + cuda_sm_2_0 + cuda_sm_3_0 + cuda_sm_3_5 + cuda_sm_4_0 + cuda_sm_5_0 + cuda_sm_6_0 + cuda_sm_7_0 + callable | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + vertex | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + fragment | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + compute | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + hull | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + domain | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + geometry | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + raygen | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + intersection | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + anyhit | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + closesthit | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + miss | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + mesh | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + amplification | textualTarget + hlsl + sm_4_0 + sm_4_1 + sm_5_0 + sm_5_1 + sm_6_0 + sm_6_1 + sm_6_2 + sm_6_3 + sm_6_4 + sm_6_5 + callable', which is incompatible with the current compilation target 'spirv_1_0 + spirv_1_1 + spirv_1_2 + spirv_1_3 + spirv_1_4 + spirv_1_5 + fragment + SPV_KHR_fragment_shader_barycentric + SPV_EXT_fragment_fully_covered + SPV_EXT_shader_atomic_float_add + SPV_EXT_shader_atomic_float_min_max + SPV_EXT_mesh_shader + SPV_KHR_ray_tracing + SPV_KHR_ray_query + SPV_GOOGLE_user_type'.
uint4 main(int4 input0 : ATTR0, uint4 input1 : ATTR1) : SV_Target {
      ^~~~
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see using of 'WaveMultiPrefixProduct'
hlsl.meta.slang(14867): note: see definition of 'WaveMultiPrefixProduct'

Guessing this is telling me that this function isn't supported by -target spirv?

ArielG-NV commented 1 week ago

Guessing this is telling me that this function isn't supported by -target spirv?

This is a correct interpretation of the error. WaveMultiPrefixProduct is the function causing the error in question due to only supporting hlsl and cuda.

This is related to:

  1. 4347 to make the error easier to read

  2. 4172 to more precisely describe the function causing the error

jkwak-work commented 3 days ago

I suggest to close this issue as a duplicate to #4347.