summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-04 15:55:06 -0700
committerGitHub <noreply@github.com>2023-08-04 15:55:06 -0700
commit856086cf2ac6fb1544b5b08ffa64b2f01931d35c (patch)
tree67f521b4750c01263ce8038cfe6d771b7c3b9cfb /source/slang
parenta2d90fb275962da84611160f8ddd74d934a68dbd (diff)
Add option to use original entrypoint in spirv output. (#3047)
* Add option to use original entrypoint in spirv output. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-compiler.cpp15
-rw-r--r--source/slang/slang-hlsl-to-vulkan-layout-options.h7
-rw-r--r--source/slang/slang-options.cpp9
3 files changed, 27 insertions, 4 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 4e1ab8e98..12e96d7bb 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1222,11 +1222,18 @@ namespace Slang
auto entryPoint = getEntryPoint(entryPointIndex);
profile = getEffectiveProfile(entryPoint, targetReq);
- options.entryPointName = allocator.allocate(getText(entryPoint->getName()));
- auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex);
- if (entryPointNameOverride.getLength() != 0)
+ if (getTargetReq()->getHLSLToVulkanLayoutOptions() && !getTargetReq()->getHLSLToVulkanLayoutOptions()->getUseOriginalEntryPointName())
{
- options.entryPointName = allocator.allocate(entryPointNameOverride);
+ }
+ else
+ {
+
+ options.entryPointName = allocator.allocate(getText(entryPoint->getName()));
+ auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex);
+ if (entryPointNameOverride.getLength() != 0)
+ {
+ options.entryPointName = allocator.allocate(entryPointNameOverride);
+ }
}
}
else
diff --git a/source/slang/slang-hlsl-to-vulkan-layout-options.h b/source/slang/slang-hlsl-to-vulkan-layout-options.h
index 4ae169d90..2d24dfccb 100644
--- a/source/slang/slang-hlsl-to-vulkan-layout-options.h
+++ b/source/slang/slang-hlsl-to-vulkan-layout-options.h
@@ -119,6 +119,8 @@ public:
/// True if the compiler should invert the Y coordinate of any SV_Position output.
bool shouldInvertY() const { return m_invertY; }
+ bool getUseOriginalEntryPointName() const { return m_useOriginalEntryPointName; }
+
/// Given an kind and a binding infer the vulkan binding.
/// Will return an invalid binding if one is not found
Binding inferBinding(Kind kind, const Binding& inBinding) const;
@@ -145,6 +147,8 @@ public:
void setInvertY(bool value) { m_invertY = value; }
+ void setUseOriginalEntryPointName(bool value) { m_useOriginalEntryPointName = value; }
+
/// Ctor
HLSLToVulkanLayoutOptions();
@@ -171,6 +175,9 @@ protected:
/// Whether to invert the Y coordinate of SV_Position output.
bool m_invertY = false;
+
+ /// If set, will use the original entry point name in the generated SPIRV instead of "main".
+ bool m_useOriginalEntryPointName = false;
};
} // namespace Slang
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index e59109b37..b31a502e7 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -93,6 +93,8 @@ enum class OptionKind
VulkanBindShift,
VulkanBindGlobals,
VulkanInvertY,
+ VulkanUseEntryPointName,
+
GLSLForceScalarLayout,
EnableEffectAnnotations,
@@ -498,6 +500,7 @@ void initCommandOptions(CommandOptions& options)
{ OptionKind::VulkanBindGlobals, "-fvk-bind-globals", "-fvk-bind-globals <N> <descriptor-set>",
"Places the $Globals cbuffer at descriptor set <descriptor-set> and binding <N>."},
{ OptionKind::VulkanInvertY, "-fvk-invert-y", nullptr, "Negates (additively inverts) SV_Position.y before writing to stage output."},
+ { OptionKind::VulkanUseEntryPointName, "-fvk-use-entrypoint-name", nullptr, "Uses the entrypoint name from the source instead of 'main' in the spirv output."},
{ OptionKind::EnableEffectAnnotations,
"-enable-effect-annotations", nullptr,
"Enables support for legacy effect annotation syntax."},
@@ -2016,6 +2019,12 @@ SlangResult OptionsParser::_parse(
m_hlslToVulkanLayoutOptions->setInvertY(true);
break;
}
+ case OptionKind::VulkanUseEntryPointName:
+ {
+ // -fvk-use-entrypoint-name
+ m_hlslToVulkanLayoutOptions->setUseOriginalEntryPointName(true);
+ break;
+ }
case OptionKind::Profile: SLANG_RETURN_ON_FAIL(_parseProfile(arg)); break;
case OptionKind::Capability:
{