From 83a42cb76feb1f702ff730040f359cabc01c571a Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 4 Apr 2025 15:25:20 +0800 Subject: Do no fail on missing no_diff annotation on non-differentiable (inputs and output) function outputs (#6737) Closes https://github.com/shader-slang/slang/issues/6632 --- source/slang/slang-ir-autodiff.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/slang/slang-ir-autodiff.cpp') diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index afd698e8b..f70e30b72 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -147,6 +147,20 @@ bool isNoDiffType(IRType* paramType) return false; } +// Return true if the result type and all the parameter types are no_diff +bool isNeverDiffFuncType(IRFuncType* const funcType) +{ + const auto resultType = funcType->getResultType(); + if (!isNoDiffType(resultType)) + return false; + for (const auto p : funcType->getParamTypes()) + { + if (!isNoDiffType(p)) + return false; + } + return true; +} + IRInst* lookupForwardDerivativeReference(IRInst* primalFunction) { if (auto jvpDefinition = primalFunction->findDecoration()) -- cgit v1.2.3