From a2b9e376b2d54283000a0fe0c48e6e1912d8a333 Mon Sep 17 00:00:00 2001 From: sriramm-nv <85252063+sriramm-nv@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:12:04 -0700 Subject: ForceInline SampleLevel to allow decorations to be applied (#3977) Fixes #3969 NonUniformResourceInfo instruction is applied as a Decoration on the backing resource. With the following shader, this is applied to the Function Call. res.rgb *= g_bindless_Texture2D [NonUniformResourceIndex (val.x)].SampleLevel(g_Sampler, v, 0.0).rgb; as shown below: {145371} let %1826 : Int = nonUniformResourceIndex(%1789) {177146} let %1828 : Vec(Float, 4 : Int) = call %SampleLevel(%1826, %sampler, %1827, 0 : Float) This patch ForceInlines SampleLevel intrinsic function call so that the Decoration is correctly applied on the resource. --- source/slang/hlsl.meta.slang | 4 ++++ source/slang/slang-ir-autodiff-fwd.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 7905042d7..3576e46e3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -618,6 +618,7 @@ extension __TextureImpl } [__readNone] + [ForceInline] T SampleLevel(vector location, float level) { __target_switch @@ -668,6 +669,7 @@ extension __TextureImpl } [__readNone] + [ForceInline] T SampleLevel(vector location, float level, constexpr vector offset) { __target_switch @@ -1045,6 +1047,7 @@ extension __TextureImpl } [__readNone] + [ForceInline] T SampleLevel(SamplerState s, vector location, float level) { __target_switch @@ -1096,6 +1099,7 @@ extension __TextureImpl } [__readNone] + [ForceInline] T SampleLevel(SamplerState s, vector location, float level, constexpr vector offset) { __target_switch diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index 546d24a4d..858d94514 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -1920,6 +1920,22 @@ InstPair ForwardDiffTranscriber::transcribeInstImpl(IRBuilder* builder, IRInst* case kIROp_GetSequentialID: case kIROp_GetStringHash: case kIROp_SPIRVAsm: + case kIROp_SPIRVAsmOperandLiteral: + case kIROp_SPIRVAsmOperandInst: + case kIROp_SPIRVAsmOperandRayPayloadFromLocation: + case kIROp_SPIRVAsmOperandRayAttributeFromLocation: + case kIROp_SPIRVAsmOperandRayCallableFromLocation: + case kIROp_SPIRVAsmOperandEnum: + case kIROp_SPIRVAsmOperandBuiltinVar: + case kIROp_SPIRVAsmOperandGLSL450Set: + case kIROp_SPIRVAsmOperandDebugPrintfSet: + case kIROp_SPIRVAsmOperandId: + case kIROp_SPIRVAsmOperandResult: + case kIROp_SPIRVAsmOperandTruncate: + case kIROp_SPIRVAsmOperandEntryPoint: + case kIROp_SPIRVAsmOperandSampledType: + case kIROp_SPIRVAsmOperandImageType: + case kIROp_SPIRVAsmOperandSampledImageType: case kIROp_DebugLine: case kIROp_DebugVar: case kIROp_DebugValue: -- cgit v1.2.3