diff options
| author | Yong He <yonghe@outlook.com> | 2022-01-21 12:13:23 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-21 12:13:23 -0800 |
| commit | 7cff340b10b27f82781335093759bbdc19cd2865 (patch) | |
| tree | 15a983c4fdfb68b700ab532d5d2a684e8727e6b4 /source/slang/slang-ir-link.cpp | |
| parent | f85bc7ae98486b37518958e659f659f1ff9b125c (diff) | |
Add entry-point name override feature. (#2089)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
| -rw-r--r-- | source/slang/slang-ir-link.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index 77998fba1..385b536dc 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -809,7 +809,8 @@ static void maybeCopyLayoutInformationToParameters( IRFunc* specializeIRForEntryPoint( IRSpecContext* context, - String const& mangledName) + String const& mangledName, + String const& nameOverride) { // We start by looking up the IR symbol that // matches the mangled name given to the @@ -848,6 +849,20 @@ IRFunc* specializeIRForEntryPoint( // auto clonedVal = cloneGlobalValue(context, originalVal); + if (nameOverride.getLength()) + { + if (auto entryPointDecor = clonedVal->findDecoration<IREntryPointDecoration>()) + { + IRInst* operands[] = { + entryPointDecor->getProfileInst(), + context->builder->getStringValue(nameOverride.getUnownedSlice()), + entryPointDecor->getModuleName()}; + context->builder->addDecoration( + clonedVal, IROp::kIROp_EntryPointDecoration, operands, 3); + entryPointDecor->removeAndDeallocate(); + } + } + // In the case where the user is requesting a specialization // of a generic entry point, we have a bit of a problem. // @@ -1425,7 +1440,8 @@ LinkedIR linkIR( for (auto entryPointIndex : entryPointIndices) { auto entryPointMangledName = program->getEntryPointMangledName(entryPointIndex); - irEntryPoints.add(specializeIRForEntryPoint(context, entryPointMangledName)); + auto nameOverride = program->getEntryPointNameOverride(entryPointIndex); + irEntryPoints.add(specializeIRForEntryPoint(context, entryPointMangledName, nameOverride)); } // Layout information for global shader parameters is also required, |
