diff options
| author | Pankaj Mistry <63069047+pmistryNV@users.noreply.github.com> | 2023-12-16 12:48:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-16 12:48:27 -0800 |
| commit | b6da04424aff71ddba9629c94401a9a897b152a0 (patch) | |
| tree | f22199a0ddab9f82166ea4763f1903d5ae2b6498 /source | |
| parent | eb89ccb177881f10a4ac3f88fcbe033703d9ecd5 (diff) | |
Fix nonuniform decoration on direct-to-spirv backend path. (#3338) (#3417)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 945dfa862..2c5f384a3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -5963,6 +5963,18 @@ __generic<let N : int> float noise(vector<float, N> x) /// to this function as necessary in output code, rather than make this /// the user's responsibility, so that the default behavior of the language /// is more semantically "correct." +[ForceInline] +T __copyObject<T>(T v) +{ + __target_switch { + case spirv: + return spirv_asm { + result:$$T = OpCopyObject $v; + }; + } +} + + __glsl_extension(GL_EXT_nonuniform_qualifier) [__readNone] [ForceInline] @@ -5975,12 +5987,13 @@ uint NonUniformResourceIndex(uint index) case glsl: __intrinsic_asm "nonuniformEXT"; case spirv: + var indexCopy = __copyObject(index); spirv_asm { OpCapability ShaderNonUniform; - OpDecorate $index NonUniform; + OpDecorate $indexCopy NonUniform; }; - return index; + return indexCopy; default: return index; } @@ -5988,6 +6001,7 @@ uint NonUniformResourceIndex(uint index) __glsl_extension(GL_EXT_nonuniform_qualifier) [__readNone] +[ForceInline] int NonUniformResourceIndex(int index) { __target_switch @@ -5997,12 +6011,13 @@ int NonUniformResourceIndex(int index) case glsl: __intrinsic_asm "nonuniformEXT"; case spirv: + var indexCopy = __copyObject(index); spirv_asm { OpCapability ShaderNonUniform; - OpDecorate $index NonUniform; + OpDecorate $indexCopy NonUniform; }; - return index; + return indexCopy; default: return index; } |
