summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler-options.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-29 18:02:53 -0800
committerGitHub <noreply@github.com>2024-02-29 18:02:53 -0800
commit3ade07303783605ddef8c0f0c5237952c903798d (patch)
treed41b82eae557d82ad642812bd84a8c434d2e1bb3 /source/slang/slang-compiler-options.cpp
parent458d66300f7180a0e5d432a203225305a83fc222 (diff)
Fix various crashes when generating debug info. (#3650)
* Fix crash when generating debug info for geometry shaders. * Fix. * Fix source language field in DebugCompilationUnit. * Fix. * Emit DebugEntryPoint inst. * Add trivial test. * Cleanup. * More cleanup.
Diffstat (limited to 'source/slang/slang-compiler-options.cpp')
-rw-r--r--source/slang/slang-compiler-options.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/source/slang/slang-compiler-options.cpp b/source/slang/slang-compiler-options.cpp
index aca5fb8db..100a5719f 100644
--- a/source/slang/slang-compiler-options.cpp
+++ b/source/slang/slang-compiler-options.cpp
@@ -20,6 +20,114 @@ namespace Slang
}
}
+ void CompilerOptionSet::writeCommandLineArgs(Session* globalSession, StringBuilder& sb)
+ {
+ for (auto& option : options)
+ {
+ auto optionInfoIndex = globalSession->m_commandOptions.findOptionByUserValue(CommandOptions::UserValue(option.key));
+ if (optionInfoIndex == -1)
+ continue;
+ auto optionInfo = globalSession->m_commandOptions.getOptionAt(optionInfoIndex);
+ auto nameCommaIndex = optionInfo.names.indexOf(',');
+ if (nameCommaIndex == -1) nameCommaIndex = optionInfo.names.getLength();
+ auto name = optionInfo.names.head(nameCommaIndex);
+ switch (option.key)
+ {
+ case CompilerOptionName::Capability:
+ for (auto v : option.value)
+ {
+ sb << " " << optionInfo.names << " " << v.stringValue;
+ }
+ break;
+ case CompilerOptionName::Include:
+ for (auto v : option.value)
+ {
+ sb << " -I \"" << v.stringValue << "\"";
+ }
+ break;
+ case CompilerOptionName::MacroDefine:
+ for (auto v : option.value)
+ {
+ sb << " -D" << v.stringValue;
+ if (v.stringValue2.getLength())
+ sb << "=" << v.stringValue2;
+ }
+ break;
+ case CompilerOptionName::VulkanBindShift: // intValue0 (higher 8 bits): kind; intValue0(higher bits): set; intValue1: shift
+ for (auto v : option.value)
+ {
+ uint8_t kind;
+ int set, shift;
+ v.unpackInt3(kind, set, shift);
+ switch ((HLSLToVulkanLayoutOptions::Kind)(kind))
+ {
+ case HLSLToVulkanLayoutOptions::Kind::UnorderedAccess:
+ sb << " -fvk-u-shift";
+ break;
+ case HLSLToVulkanLayoutOptions::Kind::Sampler:
+ sb << " -fvk-s-shift";
+ break;
+ case HLSLToVulkanLayoutOptions::Kind::ShaderResource:
+ sb << " -fvk-t-shift";
+ break;
+ case HLSLToVulkanLayoutOptions::Kind::ConstantBuffer:
+ sb << " -fvk-b-shift";
+ break;
+ default:
+ continue;
+ }
+ sb << " " << shift << " " << set;
+ }
+ break;
+ case CompilerOptionName::VulkanBindShiftAll: // intValue0: set; intValue1: shift
+ for (auto v : option.value)
+ {
+ sb << " -fvk-all-shift " << v.intValue2 << " " << v.intValue;
+ }
+ break;
+ case CompilerOptionName::VulkanBindGlobals: // intValue0: index; intValue1: set
+ for (auto v : option.value)
+ {
+ sb << " " << name << v.intValue << " " << v.intValue2;
+ }
+ break;
+ case CompilerOptionName::Optimization:
+ for (auto v : option.value)
+ {
+ sb << " -O" << v.intValue;
+ }
+ break;
+ case CompilerOptionName::DownstreamArgs:
+ for (auto v : option.value)
+ {
+ List<UnownedStringSlice> lines;
+ StringUtil::split(v.stringValue2.getUnownedSlice(), '\n', lines);
+ for (auto l : lines)
+ {
+ sb << " -x" << v.stringValue << " " << l.trim();
+ }
+ }
+ break;
+ case CompilerOptionName::EmitSpirvDirectly:
+ case CompilerOptionName::GLSLForceScalarLayout:
+ case CompilerOptionName::MatrixLayoutRow:
+ case CompilerOptionName::MatrixLayoutColumn:
+ case CompilerOptionName::VulkanInvertY:
+ case CompilerOptionName::VulkanUseEntryPointName:
+ case CompilerOptionName::VulkanUseGLLayout:
+ case CompilerOptionName::VulkanEmitReflection:
+ case CompilerOptionName::EnableEffectAnnotations:
+ case CompilerOptionName::DefaultImageFormatUnknown:
+ case CompilerOptionName::DisableDynamicDispatch:
+ case CompilerOptionName::DisableSpecialization:
+ case CompilerOptionName::DumpIntermediates:
+ if (option.value.getCount() && option.value[0].intValue != 0)
+ sb << " " << name;
+ break;
+ }
+ }
+ }
+
void CompilerOptionSet::buildHash(DigestBuilder<SHA1>& builder)
{
for (auto& kv : options)