summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2025-09-29 09:33:45 +0300
committerGitHub <noreply@github.com>2025-09-29 06:33:45 +0000
commitd5f3f477918769338dd5baa73ff560d10a5ca7e9 (patch)
tree7de9b237eff9a50e7ef16edbd88dfdeafee74aab /source/slang
parentd3093deb49d1088ede6c3dcd418575bfa4bcd732 (diff)
Update function type after inserting KernelContext parameter (#8551)
Without this, there are functions with missing parameters in their type in the IR after running the `introduceExplicitGlobalContext` pass: ``` [layout(%15)] [export("_SV4test12outputBuffer")] [nameHint("outputBuffer")] let %outputBuffer : _ = key [noSideEffect] [export("_S4test7dostuffp1pi_ff")] [nameHint("dostuff")] func %dostuff : Func(Float, Float) { block %34( [nameHint("f")] param %f : Float, [nameHint("kernelContext")] param %kernelContext : Ptr(%KernelContext, 0 : UInt64, 1 : UInt64)): let %35 : Float = mul(%f, %f) let %36 : Ptr(ConstantBuffer(%GlobalParams, DefaultLayout), 0 : UInt64, 1 : UInt64) = get_field_addr(%kernelContext, %globalParams) let %37 : ConstantBuffer(%GlobalParams, DefaultLayout) = load(%36) let %38 : Ptr(RWStructuredBuffer(Float, DefaultLayout, %20)) = get_field_addr(%37, %outputBuffer) let %39 : RWStructuredBuffer(Float, DefaultLayout, %20) = load(%38) let %40 : Ptr(Float) = rwstructuredBufferGetElementPtr(%39, 1 : Int) let %41 : Float = load(%40) let %42 : Float = mul(%35, %41) return_val(%42) } ``` Not sure why this doesn't seem to negatively affect existing targets, but it sure is an issue for the LLVM target I'm working on. I could've left this fix for that PR, but I want to check now if this causes any issues with the existing targets using the CI. This also happens with the entry point functions, where the function type is not updated after adding `ComputeThreadVaryingInput`. This had no effect in the C++ target because `convertEntryPointPtrParamsToRawPtrs(irModule);` is called right after and fixes it.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-ir-explicit-global-context.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/slang-ir-explicit-global-context.cpp b/source/slang/slang-ir-explicit-global-context.cpp
index dd07db883..515992cee 100644
--- a/source/slang/slang-ir-explicit-global-context.cpp
+++ b/source/slang/slang-ir-explicit-global-context.cpp
@@ -564,6 +564,9 @@ struct IntroduceExplicitGlobalContextPass
builder.emitStore(fieldPtr, var);
}
}
+
+ // Update entry point function type after potentially adding parameters.
+ fixUpFuncType(entryPointFunc);
}
void replaceUsesOfGlobalParam(IRGlobalParam* globalParam)
@@ -723,6 +726,9 @@ struct IntroduceExplicitGlobalContextPass
addKernelContextNameHint(contextParam);
contextParam->insertBefore(firstBlock->getFirstOrdinaryInst());
+ // Update the type of the function to reflect this new parameter.
+ fixUpFuncType(func);
+
// The new parameter can be registered as the context value
// to be used for `func` right away.
//