diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-07-06 10:21:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-06 10:21:50 -0400 |
| commit | 946a1b294e1e511d4bb32817d0c82828b5305113 (patch) | |
| tree | 207cc9ce818b40fe4e3c39cff5cdcc4e854238a7 | |
| parent | b9ac4ace1133b12161faa70e61139cbdfc55db83 (diff) | |
Work around for NonUniformResourceIndex with non integral types. (#2963)
* Work around for NonUniformResourceIndex with non integral types.
* Make the non integral NonUniformResourceIndex, inline early.
* Add a depreciated warning.
| -rw-r--r-- | source/slang/hlsl.meta.slang | 7 | ||||
| -rw-r--r-- | tests/cross-compile/non-uniform-indexing.slang | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 89a34588c..05fcee323 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -3202,6 +3202,13 @@ int NonUniformResourceIndex(int index) return index; } +/// HLSL allows NonUniformResourceIndex around non int/uint types. +/// It's effect is presumably to ignore it, which the following implementation does. +/// We should also look to add a warning for this scenario. +[__unsafeForceInlineEarly] +[deprecated("NonUniformResourceIndex on a type other than uint/int is depreciated and has no effect")] +T NonUniformResourceIndex<T>(T value) { return value; } + // Normalize a vector __generic<T : __BuiltinFloatingPointType, let N : int> __target_intrinsic(hlsl) diff --git a/tests/cross-compile/non-uniform-indexing.slang b/tests/cross-compile/non-uniform-indexing.slang index 747ca2eef..22e00a212 100644 --- a/tests/cross-compile/non-uniform-indexing.slang +++ b/tests/cross-compile/non-uniform-indexing.slang @@ -1,7 +1,7 @@ //TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment //TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment -verify-debug-serial-ir -// Confirm that `NonUniformResourceIndex` translates to SPIR-V as expeted +// Confirm that `NonUniformResourceIndex` translates to SPIR-V as expected Texture2D t[10]; SamplerState s; |
