summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 94f350ce3..99caed8f0 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -70,6 +70,56 @@
namespace Slang
{
+#define SLANG_CODE_GEN_TARGETS(x) \
+ x("unknown", Unknown) \
+ x("none", None) \
+ x("glsl", GLSL) \
+ x("glsl-vulkan", GLSL_Vulkan) \
+ x("glsl-vulkan-one-desc", GLSL_Vulkan_OneDesc) \
+ x("hlsl", HLSL) \
+ x("spirv", SPIRV) \
+ x("spirv-asm,spirv-assembly", SPIRVAssembly) \
+ x("dxbc", DXBytecode) \
+ x("dxbc-asm,dxbc-assembly", DXBytecodeAssembly) \
+ x("dxil", DXIL) \
+ x("dxil-asm,dxil-assembly", DXILAssembly) \
+ x("c", CSource) \
+ x("cpp", CPPSource)
+
+#define SLANG_CODE_GEN_INFO(names, e) \
+ { CodeGenTarget::e, UnownedStringSlice::fromLiteral(names) },
+
+ struct CodeGenTargetInfo
+ {
+ CodeGenTarget target;
+ UnownedStringSlice names;
+ };
+
+ static const CodeGenTargetInfo s_codeGenTargetInfos[] =
+ {
+ SLANG_CODE_GEN_TARGETS(SLANG_CODE_GEN_INFO)
+ };
+
+ CodeGenTarget calcCodeGenTargetFromName(const UnownedStringSlice& name)
+ {
+ for (int i = 0; i < SLANG_COUNT_OF(s_codeGenTargetInfos); ++i)
+ {
+ const auto& info = s_codeGenTargetInfos[i];
+
+ SLANG_ASSERT(i == int(info.target));
+
+ if (StringUtil::indexOfInSplit(info.names, ',', name) >= 0)
+ {
+ return info.target;
+ }
+ }
+ return CodeGenTarget::Unknown;
+ }
+ UnownedStringSlice getCodeGenTargetName(CodeGenTarget target)
+ {
+ // Return the first name
+ return StringUtil::getAtInSplit(s_codeGenTargetInfos[int(target)].names, ',', 0);
+ }
// CompileResult