diff options
Diffstat (limited to 'source/slang/slang-compiler.cpp')
| -rw-r--r-- | source/slang/slang-compiler.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index a5a09204b..7d2dbed0d 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -2535,8 +2535,11 @@ namespace Slang { if (m_entryPoints.getCount() > 0) return; - - for (auto globalDecl : m_moduleDecl->members) + _discoverEntryPointsImpl(m_moduleDecl, sink, targets); + } + void Module::_discoverEntryPointsImpl(ContainerDecl* containerDecl, DiagnosticSink* sink, const List<RefPtr<TargetRequest>>& targets) + { + for (auto globalDecl : containerDecl->members) { auto maybeFuncDecl = globalDecl; if (auto genericDecl = as<GenericDecl>(maybeFuncDecl)) @@ -2544,13 +2547,19 @@ namespace Slang maybeFuncDecl = genericDecl->inner; } + if (as<NamespaceDeclBase>(globalDecl) || as<FileDecl>(globalDecl) || as<StructDecl>(globalDecl)) + { + _discoverEntryPointsImpl(as<ContainerDecl>(globalDecl), sink, targets); + continue; + } + auto funcDecl = as<FuncDecl>(maybeFuncDecl); if (!funcDecl) continue; Profile profile; bool resolvedStageOfProfileWithEntryPoint = resolveStageOfProfileWithEntryPoint(profile, getLinkage()->m_optionSet, targets, funcDecl, sink); - if(!resolvedStageOfProfileWithEntryPoint) + if (!resolvedStageOfProfileWithEntryPoint) { // If there isn't a [shader] attribute, look for a [numthreads] attribute // since that implicitly means a compute shader. We'll not do this when compiling for @@ -2560,7 +2569,7 @@ namespace Slang bool allTargetsCUDARelated = true; for (auto target : targets) { - if (!isCUDATarget(target) && + if (!isCUDATarget(target) && target->getTarget() != CodeGenTarget::PyTorchCppBinding) { allTargetsCUDARelated = false; @@ -2614,6 +2623,5 @@ namespace Slang _addEntryPoint(entryPoint); } } - } |
