shader-slang / slang

Making it easier to work with shaders
MIT License
1.97k stars 167 forks source link

Capability System: Redesign how failed capability providence is described to a user #4172

Closed ArielG-NV closed 1 month ago

ArielG-NV commented 3 months ago

Currently in the capabilities system, erroring once we reach a stage of checking EntryPoints<->compileTarget (Diagnostics::entryPointUsesUnavailableCapability) produces assumptions of what went wrong.

These assumptions assumes based on providence of a single Decl that any incompatible capability may be the problem. This erroring works well when the problem is straight-forward or the function has little capabilities defined. When the problem is within a function with many overlapping capabilities the current "providence" tracking provides little assistance in erroring due to only tracking a single "providence".

One solution to this would be to redesign the approach to store UIntSets of callee and parent functions that remove a target

ArielG-NV commented 1 month ago

example of why this needs fixing (notice the repeat of errors):


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'```
jkwak-work commented 1 month ago

I think this issue needs a "repro steps". Once we have a repro steps, anybody can pick it up and work on it. And we can also verify the fix later by running the repro steps again.

ArielG-NV commented 1 month ago

Repro: #4443