From e743c17f72ab332f7eb467f02dd9567f3f8d3de0 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 17 Jan 2025 08:56:23 -0800 Subject: [PATCH] Fix `-capability` arg in SPIRV debug command line output. (#6114) --- source/slang/slang-compiler-options.cpp | 16 +++++++++++++--- tests/spirv/cmd-arg-debug-info.slang | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/spirv/cmd-arg-debug-info.slang diff --git a/source/slang/slang-compiler-options.cpp b/source/slang/slang-compiler-options.cpp index 9b70917560..8a27f6fce5 100644 --- a/source/slang/slang-compiler-options.cpp +++ b/source/slang/slang-compiler-options.cpp @@ -54,11 +54,21 @@ void CompilerOptionSet::writeCommandLineArgs(Session* globalSession, StringBuild switch (option.key) { case CompilerOptionName::Capability: - for (auto v : option.value) { - sb << " " << optionInfo.names << " " << v.stringValue; + StringBuilder subBuilder; + for (auto v : option.value) + { + if (subBuilder.getLength() != 0) + subBuilder << "+"; + if (v.kind == CompilerOptionValueKind::Int) + subBuilder << capabilityNameToString((CapabilityName)v.intValue); + else + subBuilder << v.stringValue; + } + if (subBuilder.getLength()) + sb << " " << optionInfo.names << " " << subBuilder.produceString(); + break; } - break; case CompilerOptionName::Include: for (auto v : option.value) { diff --git a/tests/spirv/cmd-arg-debug-info.slang b/tests/spirv/cmd-arg-debug-info.slang new file mode 100644 index 0000000000..da5cebad0a --- /dev/null +++ b/tests/spirv/cmd-arg-debug-info.slang @@ -0,0 +1,5 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -g3 -emit-spirv-directly -profile sm_6_6+spirv_1_5 +// CHECK: OpString "-target spirv {{.*}} -capability spirv_1_5 +[numthreads(1,1,1)] +void computeMain() +{} \ No newline at end of file