diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2025-08-14 12:27:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-14 19:27:55 +0000 |
| commit | dd06524f523cdac9c753801ce9c3992f66ae5576 (patch) | |
| tree | a73cad28075d1beaa04ba50dc4b668f3097c87b2 /tests | |
| parent | ceb2e8d04885d55dd9685a38977a55c4f53f202f (diff) | |
[Capability System] Fix bug where capabilities do not correctly propegate if AST-parent has target+set the AST-child does not (#8175)
Fixes: #8174
Changes:
* To determine if we propagate capabilities, we need to ensure that a
`join` will do nothing (optimization since `join` is expensive + caching
data for the `join` adds up to be expensive). This logic was changed in
`slang-check-decl.cpp` since the current logic was incorrect.
* A parent could have the set `metal+glsl` and the use-site could have
`glsl`. In this case, we will not remove `metal` from the parent since
`{metal+glsl}.implies({glsl})` is true.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/glsl-intrinsic/shader-subgroup/shader-subgroup-arithmetic_Inclusive.slang | 6 | ||||
| -rw-r--r-- | tests/language-feature/capability/capability8.slang | 26 |
2 files changed, 30 insertions, 2 deletions
diff --git a/tests/glsl-intrinsic/shader-subgroup/shader-subgroup-arithmetic_Inclusive.slang b/tests/glsl-intrinsic/shader-subgroup/shader-subgroup-arithmetic_Inclusive.slang index 40f77ee61..b9f26ca30 100644 --- a/tests/glsl-intrinsic/shader-subgroup/shader-subgroup-arithmetic_Inclusive.slang +++ b/tests/glsl-intrinsic/shader-subgroup/shader-subgroup-arithmetic_Inclusive.slang @@ -17,9 +17,11 @@ #if 1 \ && !defined(TARGET_HLSL) \ - && !defined(TARGET_CUDA) + && !defined(TARGET_CUDA) \ + && !defined(WGPU) \ + && !defined(METAL) // hlsl does not treat boolean types with subgroup.* as a logical operator -// cuda is missing an implementation +// cuda, wgsl, and metal is missing an implementation #define TEST_when_logical_operators_are_implemented #endif diff --git a/tests/language-feature/capability/capability8.slang b/tests/language-feature/capability/capability8.slang new file mode 100644 index 000000000..2907166e0 --- /dev/null +++ b/tests/language-feature/capability/capability8.slang @@ -0,0 +1,26 @@ +//TEST:SIMPLE(filecheck=CHECK-PASS): -target glsl -entry computeMain -stage compute -profile sm_5_0 +//TEST:SIMPLE(filecheck=CHECK): -target metal -entry computeMain -stage compute -profile sm_5_0 + +// Test that we diagnose an error when calling a method that requires a capability that is not +// available in the target. + +RWStructuredBuffer<int> outputBuffer; + +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, byteaddressbuffer)] +struct Test +{ + [require(cpp_cuda_glsl_hlsl_spirv_wgsl, structuredbuffer)] + int data() + { + return 0; + } +} + +// CHECK-PASS-NOT: error 36107 +// CHECK: ([[# @LINE+1]]): error 36107{{.*}}metal +void computeMain() +{ + Test t; + // CHECK: ([[# @LINE+1]]): note: see using of 'data' + outputBuffer[0] = t.data(); +}
\ No newline at end of file |
