From 51ad07d1fbffd41c758eba172aa77ebba3204924 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 23 Feb 2025 10:31:05 -0800 Subject: Improve performance when compiling small shaders. (#6396) Improve performance when compiling small shaders. Avoid copying witness table entries that are not getting used during linking. Avoid copying auto-diff related decorations and derivative functions during linking, if the user modules doesn't use autodiff. Cache operator overload resolution results on global session, so each new Session doesn't need to repetitively run through overload resolution from scratch. --- source/slang/slang-emit.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/slang/slang-emit.cpp') diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index e20a4a90f..847c5b55c 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -475,6 +475,31 @@ void calcRequiredLoweringPassSet( } } +void diagnoseCallStack(IRInst* inst, DiagnosticSink* sink) +{ + static const int maxDepth = 5; + for (int i = 0; i < maxDepth; i++) + { + auto func = getParentFunc(inst); + if (!func) + return; + bool shouldContinue = false; + for (auto use = func->firstUse; use; use = use->nextUse) + { + auto user = use->getUser(); + if (auto call = as(user)) + { + sink->diagnose(call, Diagnostics::seeCallOfFunc, func); + inst = call; + shouldContinue = true; + break; + } + } + if (!shouldContinue) + return; + } +} + bool checkStaticAssert(IRInst* inst, DiagnosticSink* sink) { switch (inst->getOp()) @@ -498,6 +523,7 @@ bool checkStaticAssert(IRInst* inst, DiagnosticSink* sink) { sink->diagnose(inst, Diagnostics::staticAssertionFailureWithoutMessage); } + diagnoseCallStack(inst, sink); } } else -- cgit v1.2.3