Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix entrypoint naming in glsl backend. #5320

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion source/slang/slang-emit-c-like.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions tools/slang-unit-test/unit-test-find-entrypoint-nested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SLANG_UNIT_TEST(findEntryPointNested)
[shader("raygeneration")]
void inner()
{
AllMemoryBarrier();
}
[shader("raygeneration")]
void outer()
Expand All @@ -40,6 +41,13 @@ SLANG_UNIT_TEST(findEntryPointNested)
slang::SessionDesc sessionDesc = {};
sessionDesc.targetCount = 1;
sessionDesc.targets = &targetDesc;
sessionDesc.compilerOptionEntryCount = 1;
slang::CompilerOptionEntry compilerOptionEntry = {};
compilerOptionEntry.name = slang::CompilerOptionName::EmitSpirvViaGLSL;
compilerOptionEntry.value.kind = slang::CompilerOptionValueKind::Int;
compilerOptionEntry.value.intValue0 = 1;
sessionDesc.compilerOptionEntries = &compilerOptionEntry;

ComPtr<slang::ISession> session;
SLANG_CHECK(globalSession->createSession(sessionDesc, session.writeRef()) == SLANG_OK);

Expand Down
Loading