summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-07-24 12:07:39 -0700
committerGitHub <noreply@github.com>2020-07-24 12:07:39 -0700
commiteaf3f040bbdf1e8c32dbf328251b0c133ac4b250 (patch)
tree533ca42c991866aba7c4d555c1f534514ed321b6 /source
parentef9d76cf88282030c0ed269f73ab8f332f784437 (diff)
Handle case of no global parameters for CPU/CUDA (#1457)
The IR pass that introduces an explicit `KernelContext` for the CPU/CUDA back-ends was also responsible for adding an explicit parameter to the kernel entry point to receive the constant buffer (pointer) with all the global uniform parameters. However, if there were no global uniform parameters, this parameter wasn't getting introduced, which changed the signature/ABI of the generated entry point function. This change makes it so that the pass unconditionally adds a parameter. In the case where there are no global uniforms it just adds a `void*` parameter that never gets used. In order to avoid future regressions, this change also adds a test case to confirm that things work correctly when a kernel has only entry-point parameters and no global parameters.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-explicit-global-context.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/source/slang/slang-ir-explicit-global-context.cpp b/source/slang/slang-ir-explicit-global-context.cpp
index 68f23461b..8f11bce2c 100644
--- a/source/slang/slang-ir-explicit-global-context.cpp
+++ b/source/slang/slang-ir-explicit-global-context.cpp
@@ -270,6 +270,15 @@ struct IntroduceExplicitGlobalContextPass
//
globalUniformsParam->insertBefore(firstOrdinary);
}
+ else
+ {
+ // The nature of our current ABI for entry points on CPU/CUDA
+ // means that we need an explicit parameter to be *declared*
+ // for the global uniforms, even if it is never used.
+ //
+ auto placeholderParam = builder.createParam(builder.getRawPointerType());
+ placeholderParam->insertBefore(firstOrdinary);
+ }
// The `KernelContext` to use inside the entry point
// will be a local variable declared in the first block.