summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-03-28 22:14:33 -0700
committerGitHub <noreply@github.com>2022-03-28 22:14:33 -0700
commit255fd5873f65a6b01d5385c277d55612dc3cc587 (patch)
tree54eda0ae98bc9c1b30ca75e534ca203d8e03f241 /tools
parent79b81083b75dc0abdbb8184568dbe36d082e04f3 (diff)
Allow slangc to generate exe from .slang file. (#2170)
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/cpu/render-cpu.cpp2
-rw-r--r--tools/render-test/render-test-main.cpp2
-rw-r--r--tools/slang-embed/slang-embed.cpp10
-rw-r--r--tools/slang-test/slang-test-main.cpp13
4 files changed, 18 insertions, 9 deletions
diff --git a/tools/gfx/cpu/render-cpu.cpp b/tools/gfx/cpu/render-cpu.cpp
index d17cf6ea8..7e1de796a 100644
--- a/tools/gfx/cpu/render-cpu.cpp
+++ b/tools/gfx/cpu/render-cpu.cpp
@@ -1143,7 +1143,7 @@ public:
{
SLANG_RETURN_ON_FAIL(slangContext.initialize(
desc.slang,
- SLANG_HOST_CALLABLE,
+ SLANG_SHADER_HOST_CALLABLE,
"sm_5_1",
makeArray(slang::PreprocessorMacroDesc{ "__CPU__", "1" }).getView()));
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 81e8cd38a..aa0a60829 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -1204,7 +1204,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
slangPassThrough = SLANG_PASS_THROUGH_GLSLANG;
break;
case DeviceType::CPU:
- input.target = SLANG_HOST_CALLABLE;
+ input.target = SLANG_SHADER_HOST_CALLABLE;
input.profile = "";
nativeLanguage = SLANG_SOURCE_LANGUAGE_CPP;
slangPassThrough = SLANG_PASS_THROUGH_GENERIC_C_CPP;
diff --git a/tools/slang-embed/slang-embed.cpp b/tools/slang-embed/slang-embed.cpp
index 4a81c1b95..7fb865eee 100644
--- a/tools/slang-embed/slang-embed.cpp
+++ b/tools/slang-embed/slang-embed.cpp
@@ -18,7 +18,7 @@
#include "../../source/core/slang-string.h"
#include "../../source/core/slang-string-util.h"
#include "../../source/core/slang-io.h"
-
+#include "../../source/core/slang-dictionary.h"
// Utility to free pointers on scope exit
struct ScopedMemory
@@ -59,6 +59,7 @@ struct App
{
char const* appName = "slang-embed";
char const* inputPath = nullptr;
+ Slang::HashSet<Slang::String> includedFiles;
void parseOptions(int argc, char** argv)
{
@@ -89,6 +90,13 @@ struct App
{
using namespace Slang;
+ String canonicalPath;
+ if (SLANG_SUCCEEDED(Slang::Path::getCanonical(inputPath, canonicalPath)))
+ {
+ if (!includedFiles.Add(canonicalPath))
+ return;
+ }
+
// We open the input file in text mode because we are currently
// embedding textual source files. If/when this utility gets
// used for binary files another mode could be called for.
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 05be9e0de..d5f4408ed 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -759,6 +759,7 @@ static PassThroughFlags _getPassThroughFlagsForTarget(SlangCompileTarget target)
case SLANG_GLSL:
case SLANG_C_SOURCE:
case SLANG_CPP_SOURCE:
+ case SLANG_HOST_CPP_SOURCE:
case SLANG_CUDA_SOURCE:
{
return 0;
@@ -779,9 +780,9 @@ static PassThroughFlags _getPassThroughFlagsForTarget(SlangCompileTarget target)
return PassThroughFlag::Dxc;
}
- case SLANG_HOST_CALLABLE:
- case SLANG_EXECUTABLE:
- case SLANG_SHARED_LIBRARY:
+ case SLANG_SHADER_HOST_CALLABLE:
+ case SLANG_HOST_EXECUTABLE:
+ case SLANG_SHADER_SHARED_LIBRARY:
{
return PassThroughFlag::Generic_C_CPP;
}
@@ -891,7 +892,7 @@ static SlangResult _extractRenderTestRequirements(const CommandLine& cmdLine, Te
passThru = SLANG_PASS_THROUGH_GLSLANG;
break;
case RenderApiType::CPU:
- target = SLANG_HOST_CALLABLE;
+ target = SLANG_SHADER_HOST_CALLABLE;
nativeLanguage = SLANG_SOURCE_LANGUAGE_CPP;
passThru = SLANG_PASS_THROUGH_GENERIC_C_CPP;
break;
@@ -1364,7 +1365,7 @@ TestResult runSimpleTest(TestContext* context, TestInput& input)
}
// If it's executable we run it and use it's output
- if (target == SLANG_EXECUTABLE)
+ if (target == SLANG_HOST_EXECUTABLE)
{
ExecuteResult runExeRes;
if (SLANG_FAILED(_executeBinary(exeRes.standardOutput.getUnownedSlice(), runExeRes)))
@@ -1797,7 +1798,7 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i
options.sourceLanguage = (ext == "c") ? SLANG_SOURCE_LANGUAGE_C : SLANG_SOURCE_LANGUAGE_CPP;
// Build a shared library
- options.targetType = SLANG_SHARED_LIBRARY;
+ options.targetType = SLANG_SHADER_SHARED_LIBRARY;
// Compile this source
options.sourceFiles.add(filePath);