summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-02-03 22:21:29 -0800
committerGitHub <noreply@github.com>2025-02-03 22:21:29 -0800
commitbcf5302dd48668048848230ff11add27e6d78115 (patch)
tree3371d79d2a16832b9748d49cdc6764914b4d4a00
parentbc2f20aab2303f059d767729e64b54d33ce9a12a (diff)
Auto enable `-fvk-use-entrypoint-name` when there is more than one entrypoint. (#6260)
* Auto enable `-fvk-use-entrypoint-name` when there is more than one entrypoint. * Fix.
-rw-r--r--source/slang/slang-ir-glsl-legalize.cpp3
-rw-r--r--source/slang/slang-parser.cpp1
-rw-r--r--tests/spirv/multi-entrypoint-no-rename.slang12
3 files changed, 15 insertions, 1 deletions
diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp
index 04fb54924..3ca441f96 100644
--- a/source/slang/slang-ir-glsl-legalize.cpp
+++ b/source/slang/slang-ir-glsl-legalize.cpp
@@ -3722,7 +3722,8 @@ void legalizeEntryPointForGLSL(
// Rename the entrypoint to "main" to conform to GLSL standard,
// if the compile options require us to do it.
- if (!shouldUseOriginalEntryPointName(codeGenContext))
+ if (!shouldUseOriginalEntryPointName(codeGenContext) &&
+ codeGenContext->getEntryPointCount() == 1)
{
entryPointDecor->setName(builder.getStringValue(UnownedStringSlice("main")));
}
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index 4a9d0a576..0d7281e3f 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -2352,6 +2352,7 @@ static Expr* tryParseGenericApp(Parser* parser, Expr* base)
case TokenType::OpEql:
case TokenType::OpNeq:
case TokenType::OpGreater:
+ case TokenType::OpRsh:
case TokenType::EndOfFile:
{
return parseGenericApp(parser, base);
diff --git a/tests/spirv/multi-entrypoint-no-rename.slang b/tests/spirv/multi-entrypoint-no-rename.slang
new file mode 100644
index 000000000..e419f1f41
--- /dev/null
+++ b/tests/spirv/multi-entrypoint-no-rename.slang
@@ -0,0 +1,12 @@
+//TEST:SIMPLE(filecheck=CHECK): -entry missShader -entry missShader2 -target spirv
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK: OpEntryPoint MissKHR %missShader "missShader"
+// CHECK: OpEntryPoint MissKHR %missShader2 "missShader2"
+
+struct RayPayload{};
+[shader("miss")]
+void missShader(inout RayPayload payload) { }
+
+[shader("miss")]
+void missShader2(inout RayPayload payload) { } \ No newline at end of file