diff options
| author | Yong He <yonghe@outlook.com> | 2024-10-16 17:17:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-16 17:17:19 -0700 |
| commit | 2f7f48a00752b906d6a2d42cd1bb6fbf0cfeaad6 (patch) | |
| tree | 8704eae12930a7c87a8e9ef72e2a56acfeb393fc /source | |
| parent | 2ee898109006986250d5356a59003eb741a89ca4 (diff) | |
Fix entrypoint naming in glsl backend. (#5320)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 28eb7da04..b113f726e 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -1085,7 +1085,19 @@ String CLikeSourceEmitter::generateName(IRInst* inst) // use the appropriate options for glslang to // make it support a non-`main` name. // - return "main"; + // A function may have an entry-point deocration if it + // is declared by the user as an entry-point function. + // However it may not actually be compiled as an entry-point + // when generating code for targets that doesn't support + // multiple entry-points. + // We only want to emit "main" for user-marked entrypoint + // functions that are actually being selected as entrypoint + // for current compilation. We can do so by checking if + // a layout decoration existed on the function. + if (inst->findDecoration<IRLayoutDecoration>()) + { + return "main"; + } } return generateEntryPointNameImpl(entryPointDecor); |
