From 8bcffcc085b996babedfeaee674c6ad09c9b08cf Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 18 Sep 2023 06:12:30 -0700 Subject: Use direct spirv in hello-world example. (#3207) * Use direct spirv in hello-world example. * Use vulkan 1.1 * Use vulkan 1.2. * fix. * Fix test. --------- Co-authored-by: Yong He --- source/slang/slang-ir-glsl-legalize.cpp | 19 +++++++++++++++++++ source/slang/slang-ir-insts.h | 1 + 2 files changed, 20 insertions(+) (limited to 'source') diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index 866fd3a4d..b94afe611 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -2634,6 +2634,18 @@ void legalizeEntryPointParameterForGLSL( } } +bool shouldUseOriginalEntryPointName(CodeGenContext* codeGenContext) +{ + if (auto hlslOptions = codeGenContext->getTargetReq()->getHLSLToVulkanLayoutOptions()) + { + if (hlslOptions->getUseOriginalEntryPointName()) + { + return true; + } + } + return false; +} + void legalizeEntryPointForGLSL( Session* session, IRModule* module, @@ -2679,6 +2691,13 @@ void legalizeEntryPointForGLSL( context.builder = &builder; + // Rename the entrypoint to "main" to conform to GLSL standard, + // if the compile options require us to do it. + if (!shouldUseOriginalEntryPointName(codeGenContext)) + { + entryPointDecor->setName(builder.getStringValue(UnownedStringSlice("main"))); + } + // We will start by looking at the return type of the // function, because that will enable us to do an // early-out check to avoid more work. diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index d8788aa06..b88df524a 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -454,6 +454,7 @@ struct IREntryPointDecoration : IRDecoration IRStringLit* getName() { return cast(getOperand(1)); } IRStringLit* getModuleName() { return cast(getOperand(2)); } + void setName(IRStringLit* name) { setOperand(1, name); } }; IR_SIMPLE_DECORATION(CudaHostDecoration) -- cgit v1.2.3