summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/core/slang-downstream-compiler.cpp2
-rw-r--r--source/core/slang-type-text-util.cpp101
-rw-r--r--source/core/slang-type-text-util.h26
-rw-r--r--source/slang/slang-check.cpp2
-rw-r--r--source/slang/slang-compiler.cpp59
-rw-r--r--source/slang/slang-compiler.h3
-rw-r--r--source/slang/slang-emit.cpp4
-rw-r--r--source/slang/slang-options.cpp52
-rw-r--r--source/slang/slang-state-serialize.cpp4
-rw-r--r--tools/render-test/options.cpp2
-rw-r--r--tools/render-test/shader-input-layout.cpp2
-rw-r--r--tools/slang-test/slang-test-main.cpp41
12 files changed, 134 insertions, 164 deletions
diff --git a/source/core/slang-downstream-compiler.cpp b/source/core/slang-downstream-compiler.cpp
index 0a40092ea..8a795363d 100644
--- a/source/core/slang-downstream-compiler.cpp
+++ b/source/core/slang-downstream-compiler.cpp
@@ -49,7 +49,7 @@ static DownstreamCompiler::Infos _calcInfos()
void DownstreamCompiler::Desc::appendAsText(StringBuilder& out) const
{
- out << TypeTextUtil::asHumanText(type);
+ out << TypeTextUtil::getPassThroughAsHumanText(type);
// Append the version if there is a version
if (majorVersion || minorVersion)
diff --git a/source/core/slang-type-text-util.cpp b/source/core/slang-type-text-util.cpp
index b9ccc4971..376efe0a9 100644
--- a/source/core/slang-type-text-util.cpp
+++ b/source/core/slang-type-text-util.cpp
@@ -1,6 +1,7 @@
#include "slang-type-text-util.h"
+#include "slang-string-util.h"
namespace Slang
{
@@ -36,16 +37,46 @@ struct ScalarTypeInfo
UnownedStringSlice text;
};
-static const ScalarTypeInfo s_scalarTypeInfo[] =
+static const ScalarTypeInfo s_scalarTypeInfos[] =
{
#define SLANG_SCALAR_TYPE_INFO(value, text) \
{ slang::TypeReflection::ScalarType::value, UnownedStringSlice::fromLiteral(#text) },
SLANG_SCALAR_TYPES(SLANG_SCALAR_TYPE_INFO)
};
+struct CompileTargetInfo
+{
+ SlangCompileTarget target; ///< The target
+ const char* extensions; ///< Comma delimited list of extensions associated with the target
+ const char* names; ///< Comma delimited list of names associated with the target. NOTE! First name is taken as the normal display name.
+};
+
+static const CompileTargetInfo s_compileTargetInfos[] =
+{
+ { SLANG_TARGET_UNKNOWN, "", "unknown"},
+ { SLANG_TARGET_NONE, "", "none"},
+ { SLANG_HLSL, "hlsl,fx", "hlsl"},
+ { SLANG_DXBC, "dxbc", "dxbc"},
+ { SLANG_DXBC_ASM, "dxbc.asm", "dxbc-asm,dxbc-assembly" },
+ { SLANG_DXIL, "dxil", "dxil" },
+ { SLANG_DXIL_ASM, "dxil.asm", "dxil-asm,dxil-assembly" },
+ { SLANG_GLSL, "glsl,vert,frag,geom,tesc,tese,comp", "glsl" },
+ { SLANG_GLSL_VULKAN, "", "glsl-vulkan" },
+ { SLANG_GLSL_VULKAN_ONE_DESC, "", "glsl-vulkan-one-desc" },
+ { SLANG_SPIRV, "spv", "spirv" },
+ { SLANG_SPIRV_ASM, "spv.asm", "spirv-asm,spirv-assembly" },
+ { SLANG_C_SOURCE, "c", "c" },
+ { SLANG_CPP_SOURCE, "cpp,c++,cxx", "cpp,c++,cxx" },
+ { SLANG_EXECUTABLE, "exe", "exe,executable" },
+ { SLANG_SHARED_LIBRARY, "dll,so", "sharedlib,sharedlibrary,dll" },
+ { SLANG_CUDA_SOURCE, "cu", "cuda,cu" },
+ { SLANG_PTX, "ptx", "ptx" },
+ { SLANG_HOST_CALLABLE, "", "host-callable,callable" }
+};
+
} // anonymous
-/* static */UnownedStringSlice TypeTextUtil::asText(slang::TypeReflection::ScalarType scalarType)
+/* static */UnownedStringSlice TypeTextUtil::getScalarTypeName(slang::TypeReflection::ScalarType scalarType)
{
typedef slang::TypeReflection::ScalarType ScalarType;
switch (scalarType)
@@ -58,11 +89,11 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return UnownedStringSlice();
}
-/* static */slang::TypeReflection::ScalarType TypeTextUtil::asScalarType(const UnownedStringSlice& inText)
+/* static */slang::TypeReflection::ScalarType TypeTextUtil::findScalarType(const UnownedStringSlice& inText)
{
- for (Index i = 0; i < SLANG_COUNT_OF(s_scalarTypeInfo); ++i)
+ for (Index i = 0; i < SLANG_COUNT_OF(s_scalarTypeInfos); ++i)
{
- const auto& info = s_scalarTypeInfo[i];
+ const auto& info = s_scalarTypeInfos[i];
if (info.text == inText)
{
return info.type;
@@ -71,7 +102,7 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return slang::TypeReflection::ScalarType::None;
}
-/* static */UnownedStringSlice TypeTextUtil::asHumanText(SlangPassThrough type)
+/* static */UnownedStringSlice TypeTextUtil::getPassThroughAsHumanText(SlangPassThrough type)
{
switch (type)
{
@@ -87,7 +118,7 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
}
}
-/* static */SlangSourceLanguage TypeTextUtil::asSourceLanguage(const UnownedStringSlice& text)
+/* static */SlangSourceLanguage TypeTextUtil::findSourceLanguage(const UnownedStringSlice& text)
{
if (text == "c" || text == "C")
{
@@ -116,7 +147,7 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return SLANG_SOURCE_LANGUAGE_UNKNOWN;
}
-/* static */SlangPassThrough TypeTextUtil::asPassThrough(const UnownedStringSlice& slice)
+/* static */SlangPassThrough TypeTextUtil::findPassThrough(const UnownedStringSlice& slice)
{
#define SLANG_PASS_THROUGH_NAME_TO_TYPE(x, y) \
if (slice == UnownedStringSlice::fromLiteral(#x)) return SLANG_PASS_THROUGH_##y;
@@ -136,9 +167,9 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return SLANG_PASS_THROUGH_NONE;
}
-/* static */SlangResult TypeTextUtil::asPassThrough(const UnownedStringSlice& slice, SlangPassThrough& outPassThrough)
+/* static */SlangResult TypeTextUtil::findPassThrough(const UnownedStringSlice& slice, SlangPassThrough& outPassThrough)
{
- outPassThrough = asPassThrough(slice);
+ outPassThrough = findPassThrough(slice);
// It could be none on error - if it's not equal to "none" then it must be an error
if (outPassThrough == SLANG_PASS_THROUGH_NONE && slice != UnownedStringSlice::fromLiteral("none"))
{
@@ -147,7 +178,7 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return SLANG_OK;
}
-/* static */UnownedStringSlice TypeTextUtil::asText(SlangPassThrough passThru)
+/* static */UnownedStringSlice TypeTextUtil::getPassThroughName(SlangPassThrough passThru)
{
#define SLANG_PASS_THROUGH_TYPE_TO_NAME(x, y) \
case SLANG_PASS_THROUGH_##y: return UnownedStringSlice::fromLiteral(#x);
@@ -160,6 +191,54 @@ static const ScalarTypeInfo s_scalarTypeInfo[] =
return UnownedStringSlice::fromLiteral("unknown");
}
+/* static */SlangCompileTarget TypeTextUtil::findCompileTargetFromExtension(const UnownedStringSlice& slice)
+{
+ if (slice.size())
+ {
+ for (const auto& info : s_compileTargetInfos)
+ {
+ if (StringUtil::indexOfInSplit(UnownedStringSlice(info.extensions), ',', slice) >= 0)
+ {
+ return info.target;
+ }
+ }
+ }
+ return SLANG_TARGET_UNKNOWN;
+}
+
+/* static */ SlangCompileTarget TypeTextUtil::findCompileTargetFromName(const UnownedStringSlice& slice)
+{
+ if (slice.size())
+ {
+ for (const auto& info : s_compileTargetInfos)
+ {
+ if (StringUtil::indexOfInSplit(UnownedStringSlice(info.names), ',', slice) >= 0)
+ {
+ return info.target;
+ }
+ }
+ }
+ return SLANG_TARGET_UNKNOWN;
+}
+
+static Index _getTargetInfoIndex(SlangCompileTarget target)
+{
+ for (Index i = 0; i < SLANG_COUNT_OF(s_compileTargetInfos); ++i)
+ {
+ if (s_compileTargetInfos[i].target == target)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+UnownedStringSlice TypeTextUtil::getCompileTargetName(SlangCompileTarget target)
+{
+ const Index index = _getTargetInfoIndex(target);
+ // Return the first name
+ return index >= 0 ? StringUtil::getAtInSplit(UnownedStringSlice(s_compileTargetInfos[int(target)].names), ',', 0) : UnownedStringSlice();
+}
}
diff --git a/source/core/slang-type-text-util.h b/source/core/slang-type-text-util.h
index 73c1d9ef0..c4f9fb275 100644
--- a/source/core/slang-type-text-util.h
+++ b/source/core/slang-type-text-util.h
@@ -12,25 +12,35 @@ namespace Slang
/// Utility class to allow conversion of types (such as enums) to and from text types
struct TypeTextUtil
{
-
/// Get the scalar type as text.
- static Slang::UnownedStringSlice asText(slang::TypeReflection::ScalarType scalarType);
+ static Slang::UnownedStringSlice getScalarTypeName(slang::TypeReflection::ScalarType scalarType);
// Converts text to scalar type. Returns 'none' if not determined
- static slang::TypeReflection::ScalarType asScalarType(const Slang::UnownedStringSlice& text);
+ static slang::TypeReflection::ScalarType findScalarType(const Slang::UnownedStringSlice& text);
/// As human readable text
- static UnownedStringSlice asHumanText(SlangPassThrough type);
+ static UnownedStringSlice getPassThroughAsHumanText(SlangPassThrough type);
/// Given a source language name returns a source language. Name here is distinct from extension
- static SlangSourceLanguage asSourceLanguage(const UnownedStringSlice& text);
+ static SlangSourceLanguage findSourceLanguage(const UnownedStringSlice& text);
/// Given a name returns the pass through
- static SlangPassThrough asPassThrough(const UnownedStringSlice& slice);
- static SlangResult asPassThrough(const UnownedStringSlice& slice, SlangPassThrough& outPassThrough);
+ static SlangPassThrough findPassThrough(const UnownedStringSlice& slice);
+ static SlangResult findPassThrough(const UnownedStringSlice& slice, SlangPassThrough& outPassThrough);
/// Get the compilers name
- static UnownedStringSlice asText(SlangPassThrough passThru);
+ static UnownedStringSlice getPassThroughName(SlangPassThrough passThru);
+
+ /// Given a file extension determines suitable target
+ /// If doesn't match any target will return SLANG_TARGET_UNKNOWN
+ static SlangCompileTarget findCompileTargetFromExtension(const UnownedStringSlice& slice);
+
+ /// Given a name suitable target
+ /// If doesn't match any target will return SLANG_TARGET_UNKNOWN
+ static SlangCompileTarget findCompileTargetFromName(const UnownedStringSlice& slice);
+
+ /// Given a target returns the associated name.
+ static UnownedStringSlice getCompileTargetName(SlangCompileTarget target);
};
}
diff --git a/source/slang/slang-check.cpp b/source/slang/slang-check.cpp
index 77e3ffc9f..990f9a0f5 100644
--- a/source/slang/slang-check.cpp
+++ b/source/slang/slang-check.cpp
@@ -182,7 +182,7 @@ namespace Slang
SlangFuncPtr func = sharedLibrary->findFuncByName(info.name);
if (!func)
{
- UnownedStringSlice compilerName = TypeTextUtil::asText(SlangPassThrough(info.compilerType));
+ UnownedStringSlice compilerName = TypeTextUtil::getPassThroughName(SlangPassThrough(info.compilerType));
sink->diagnose(SourceLoc(), Diagnostics::failedToFindFunctionForCompiler, info.name, compilerName);
return nullptr;
}
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 65c48d2f2..94cf7f73c 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -75,65 +75,6 @@
namespace Slang
{
-
-// NOTE! These must be in the same order as the SlangCompileTarget enum
-#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) \
- x("exe,executable", Executable) \
- x("sharedlib,sharedlibrary,dll", SharedLibrary) \
- x("callable,host-callable", HostCallable) \
- x("cu,cuda", CUDASource) \
- x("ptx", PTX)
-
-#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];
-
- // If this assert fails, then the SLANG_CODE_GEN_TARGETS macro has the wrong order
- 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);
- }
-
SlangResult CompileResult::getSharedLibrary(ComPtr<ISlangSharedLibrary>& outSharedLibrary)
{
if (downstreamResult)
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 151e89b34..e337c2fff 100644
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -72,9 +72,6 @@ namespace Slang
CountOf = SLANG_TARGET_COUNT_OF,
};
- CodeGenTarget calcCodeGenTargetFromName(const UnownedStringSlice& name);
- UnownedStringSlice getCodeGenTargetName(CodeGenTarget target);
-
enum class ContainerFormat : SlangContainerFormat
{
None = SLANG_CONTAINER_FORMAT_NONE,
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index 6e3ce9c56..d5dc9cbe7 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -2,6 +2,8 @@
#include "slang-emit.h"
#include "../core/slang-writer.h"
+#include "../core/slang-type-text-util.h"
+
#include "slang-ir-bind-existentials.h"
#include "slang-ir-dce.h"
#include "slang-ir-entry-point-uniforms.h"
@@ -525,7 +527,7 @@ String emitEntryPointSourceFromIR(
if (!sourceEmitter)
{
- sink->diagnose(SourceLoc(), Diagnostics::unableToGenerateCodeForTarget, getCodeGenTargetName(target));
+ sink->diagnose(SourceLoc(), Diagnostics::unableToGenerateCodeForTarget, TypeTextUtil::getCompileTargetName(SlangCompileTarget(target)));
return String();
}
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 456c43fa6..c97439b29 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -341,50 +341,20 @@ struct OptionsParser
void addOutputPath(char const* inPath)
{
String path = String(inPath);
+ String ext = Path::getFileExt(path);
- if (!inPath) {}
-#define CASE(EXT, TARGET) \
- else if(path.endsWith(EXT)) do { addOutputPath(path, CodeGenTarget(SLANG_##TARGET)); } while(0)
-
- CASE(".hlsl", HLSL);
- CASE(".fx", HLSL);
-
- CASE(".dxbc", DXBC);
- CASE(".dxbc.asm", DXBC_ASM);
-
- CASE(".dxil", DXIL);
- CASE(".dxil.asm", DXIL_ASM);
-
- CASE(".glsl", GLSL);
- CASE(".vert", GLSL);
- CASE(".frag", GLSL);
- CASE(".geom", GLSL);
- CASE(".tesc", GLSL);
- CASE(".tese", GLSL);
- CASE(".comp", GLSL);
-
- CASE(".spv", SPIRV);
- CASE(".spv.asm", SPIRV_ASM);
-
- CASE(".c", C_SOURCE);
- CASE(".cpp", CPP_SOURCE);
-
- CASE(".exe", EXECUTABLE);
- CASE(".dll", SHARED_LIBRARY);
- CASE(".so", SHARED_LIBRARY);
-
-#undef CASE
-
- else if (path.endsWith(".slang-module") || path.endsWith(".slang-lib"))
+ if (ext == "slang-module" || ext == "slang-lib")
{
spSetOutputContainerFormat(compileRequest, SLANG_CONTAINER_FORMAT_SLANG_MODULE);
requestImpl->m_containerOutputPath = path;
}
else
{
- // Allow an unknown-format `-o`, assuming we get a target format
+ const SlangCompileTarget target = TypeTextUtil::findCompileTargetFromExtension(ext.getUnownedSlice());
+ // If the target is not found the value returned is Unknown. This is okay because
+ // we allow an unknown-format `-o`, assuming we get a target format
// from another argument.
- addOutputPath(path, CodeGenTarget::Unknown);
+ addOutputPath(path, CodeGenTarget(target));
}
}
@@ -615,7 +585,7 @@ struct OptionsParser
String name;
SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name));
- const CodeGenTarget format = calcCodeGenTargetFromName(name.getUnownedSlice());
+ const CodeGenTarget format = (CodeGenTarget)TypeTextUtil::findCompileTargetFromName(name.getUnownedSlice());
if (format == CodeGenTarget::Unknown)
{
@@ -710,7 +680,7 @@ struct OptionsParser
SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, name));
SlangPassThrough passThrough = SLANG_PASS_THROUGH_NONE;
- if (SLANG_FAILED(TypeTextUtil::asPassThrough(name.getUnownedSlice(), passThrough)))
+ if (SLANG_FAILED(TypeTextUtil::findPassThrough(name.getUnownedSlice(), passThrough)))
{
sink->diagnose(SourceLoc(), Diagnostics::unknownPassThroughTarget, name);
return SLANG_FAIL;
@@ -945,7 +915,7 @@ struct OptionsParser
String compilerText;
SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, compilerText));
- SlangSourceLanguage sourceLanguage = TypeTextUtil::asSourceLanguage(sourceLanguageText.getUnownedSlice());
+ SlangSourceLanguage sourceLanguage = TypeTextUtil::findSourceLanguage(sourceLanguageText.getUnownedSlice());
if (sourceLanguage == SLANG_SOURCE_LANGUAGE_UNKNOWN)
{
sink->diagnose(SourceLoc(), Diagnostics::unknownSourceLanguage, sourceLanguageText);
@@ -953,7 +923,7 @@ struct OptionsParser
}
SlangPassThrough compiler;
- if (SLANG_FAILED(TypeTextUtil::asPassThrough(compilerText.getUnownedSlice(), compiler)))
+ if (SLANG_FAILED(TypeTextUtil::findPassThrough(compilerText.getUnownedSlice(), compiler)))
{
sink->diagnose(SourceLoc(), Diagnostics::unknownPassThroughTarget, compilerText);
return SLANG_FAIL;
@@ -987,7 +957,7 @@ struct OptionsParser
String slice = argStr.subString(1, index - 1);
SlangPassThrough passThrough = SLANG_PASS_THROUGH_NONE;
- if (SLANG_SUCCEEDED(TypeTextUtil::asPassThrough(slice.getUnownedSlice(), passThrough)))
+ if (SLANG_SUCCEEDED(TypeTextUtil::findPassThrough(slice.getUnownedSlice(), passThrough)))
{
session->setDownstreamCompilerPath(passThrough, name.getBuffer());
continue;
diff --git a/source/slang/slang-state-serialize.cpp b/source/slang/slang-state-serialize.cpp
index 7b689e762..e98c309f8 100644
--- a/source/slang/slang-state-serialize.cpp
+++ b/source/slang/slang-state-serialize.cpp
@@ -1229,7 +1229,7 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques
default:
{
cmd.addArg("-pass-through");
- cmd.addArg(TypeTextUtil::asText(SlangPassThrough(requestState->passThroughMode)));
+ cmd.addArg(TypeTextUtil::getPassThroughName(SlangPassThrough(requestState->passThroughMode)));
break;
}
}
@@ -1253,7 +1253,7 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques
TargetRequestState& src = base.asRaw(requestState->targetRequests[i]);
cmd.addArg("-target");
- cmd.addArg(getCodeGenTargetName(CodeGenTarget(src.target)));
+ cmd.addArg(TypeTextUtil::getCompileTargetName(SlangCompileTarget(src.target)));
cmd.addArg("-profile");
cmd.addArg(Profile(src.profile).getName());
diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp
index 6591941e8..bd6d2b364 100644
--- a/tools/render-test/options.cpp
+++ b/tools/render-test/options.cpp
@@ -228,7 +228,7 @@ SlangResult parseOptions(int argc, const char*const* argv, Slang::WriterHelper s
}
UnownedStringSlice sourceLanguageText(*argCursor++);
- SlangSourceLanguage sourceLanguage = TypeTextUtil::asSourceLanguage(sourceLanguageText);
+ SlangSourceLanguage sourceLanguage = TypeTextUtil::findSourceLanguage(sourceLanguageText);
if (sourceLanguage == SLANG_SOURCE_LANGUAGE_UNKNOWN)
{
stdError.print("error: expecting unknown source language name '%s' for '%s'\n", String(sourceLanguageText).getBuffer(), arg);
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index d3c206b58..108483a2a 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -761,7 +761,7 @@ namespace renderer_test
if (scalarType != ScalarType::None && scalarType != ScalarType::Void)
{
- UnownedStringSlice text = TypeTextUtil::asText(scalarType);
+ UnownedStringSlice text = TypeTextUtil::getScalarTypeName(scalarType);
// Write out the type
writer.put("type: ");
writer.put(text);
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 79cd6c1a7..9f9ad527a 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -545,35 +545,6 @@ static PassThroughFlags _getPassThroughFlagsForTarget(SlangCompileTarget target)
}
}
-static SlangCompileTarget _getCompileTarget(const UnownedStringSlice& name)
-{
-#define CASE(NAME, TARGET) if(name == NAME) return SLANG_##TARGET;
-
- CASE("hlsl", HLSL)
- CASE("glsl", GLSL)
- CASE("dxbc", DXBC)
- CASE("dxbc-assembly", DXBC_ASM)
- CASE("dxbc-asm", DXBC_ASM)
- CASE("spirv", SPIRV)
- CASE("spirv-assembly", SPIRV_ASM)
- CASE("spirv-asm", SPIRV_ASM)
- CASE("dxil", DXIL)
- CASE("dxil-assembly", DXIL_ASM)
- CASE("dxil-asm", DXIL_ASM)
- CASE("c", C_SOURCE)
- CASE("cpp", CPP_SOURCE)
- CASE("exe", EXECUTABLE)
- CASE("sharedlib", SHARED_LIBRARY)
- CASE("dll", SHARED_LIBRARY)
- CASE("callable", HOST_CALLABLE)
- CASE("host-callable", HOST_CALLABLE)
- CASE("ptx", PTX)
- CASE("cuda", CUDA_SOURCE)
-#undef CASE
-
- return SLANG_TARGET_UNKNOWN;
-}
-
static SlangResult _extractRenderTestRequirements(const CommandLine& cmdLine, TestRequirements* ioRequirements)
{
const auto& args = cmdLine.m_args;
@@ -709,7 +680,7 @@ static SlangResult _extractSlangCTestRequirements(const CommandLine& cmdLine, Te
String passThrough;
if (SLANG_SUCCEEDED(_extractArg(cmdLine, "-pass-through", passThrough)))
{
- ioRequirements->addUsedBackEnd(TypeTextUtil::asPassThrough(passThrough.getUnownedSlice()));
+ ioRequirements->addUsedBackEnd(TypeTextUtil::findPassThrough(passThrough.getUnownedSlice()));
}
}
@@ -718,7 +689,7 @@ static SlangResult _extractSlangCTestRequirements(const CommandLine& cmdLine, Te
String targetName;
if (SLANG_SUCCEEDED(_extractArg(cmdLine, "-target", targetName)))
{
- const SlangCompileTarget target = _getCompileTarget(targetName.getUnownedSlice());
+ const SlangCompileTarget target = TypeTextUtil::findCompileTargetFromName(targetName.getUnownedSlice());
ioRequirements->addUsedBackends(_getPassThroughFlagsForTarget(target));
}
}
@@ -1010,7 +981,7 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
const Index targetIndex = args.indexOf("-target");
if (targetIndex != Index(-1) && targetIndex + 1 < args.getCount())
{
- target = _getCompileTarget(args[targetIndex + 1].getUnownedSlice());
+ target = TypeTextUtil::findCompileTargetFromName(args[targetIndex + 1].getUnownedSlice());
}
}
@@ -1548,7 +1519,7 @@ TestResult runCrossCompilerTest(TestContext* context, TestInput& input)
const Index targetIndex = args.indexOf("-target");
if (targetIndex != Index(-1) && targetIndex + 1 < args.getCount())
{
- SlangCompileTarget target = _getCompileTarget(args[targetIndex + 1].getUnownedSlice());
+ const SlangCompileTarget target = TypeTextUtil::findCompileTargetFromName(args[targetIndex + 1].getUnownedSlice());
// Check the session supports it. If not we ignore it
if (SLANG_FAILED(spSessionCheckCompileTargetSupport(context->getSession(), target)))
@@ -2074,7 +2045,7 @@ static SlangResult _compareWithType(const UnownedStringSlice& actual, const Unow
return SLANG_FAIL;
}
- scalarType = TypeTextUtil::asScalarType(split[1].trim());
+ scalarType = TypeTextUtil::findScalarType(split[1].trim());
continue;
}
@@ -2637,7 +2608,7 @@ static void _calcSynthesizedTests(TestContext* context, RenderApiType synthRende
{
//
const auto& language = srcTest.options.args[index + 1];
- SlangSourceLanguage sourceLanguage = TypeTextUtil::asSourceLanguage(language.getUnownedSlice());
+ SlangSourceLanguage sourceLanguage = TypeTextUtil::findSourceLanguage(language.getUnownedSlice());
bool isCrossCompile = true;