summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-10-14 14:03:01 -0700
committerGitHub <noreply@github.com>2024-10-14 14:03:01 -0700
commitf857815a8c0a4e8d4f35c9a49c655545fb692195 (patch)
tree78fecf229aece79d27d4d42664eda267706670c5
parent5126d58ab2252357014df4136a4a1e07c7c2d5f4 (diff)
Misc build fixes. (#5271)
* Don't use __assume for SLANG_ASSERT + build fixes. * Fix. * build slang-wasm conditionally * Fix. * revert retry open file * revert include. * another attempt of silencing compiler warnings. * revert assume change.
-rw-r--r--CMakeLists.txt2
-rw-r--r--docs/user-guide/a3-02-reference-capability-atoms.md30
-rw-r--r--source/slang-wasm/slang-wasm.cpp7
-rw-r--r--source/slang/CMakeLists.txt2
-rw-r--r--source/slang/slang-check-decl.cpp2
-rw-r--r--source/slangc/main.cpp2
-rw-r--r--tools/slang-capability-generator/capability-generator-main.cpp5
-rw-r--r--tools/slang-generate/main.cpp5
8 files changed, 45 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0d710c137..8c5003401 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -382,7 +382,7 @@ endif()
#
# This is an executable target because emcmake produces .a files without bindings if you just create a static library
# https://stackoverflow.com/questions/63622009/static-library-built-with-cmake-as-a-with-emscripten-instead-of-wasm-js
-if(EMSCRIPTEN)
+if (EMSCRIPTEN)
slang_add_target(
source/slang-wasm
EXECUTABLE
diff --git a/docs/user-guide/a3-02-reference-capability-atoms.md b/docs/user-guide/a3-02-reference-capability-atoms.md
index 993c581b6..f8f1b8eb7 100644
--- a/docs/user-guide/a3-02-reference-capability-atoms.md
+++ b/docs/user-guide/a3-02-reference-capability-atoms.md
@@ -42,6 +42,9 @@ Targets
`spirv`
> Represents the SPIR-V code generation target.
+`wgsl`
+> Represents the WebGPU shading language code generation target.
+
Stages
----------------------
*Capabilities to specify code generation stages (`vertex`, `fragment`...)*
@@ -690,9 +693,15 @@ Compound Capabilities
`cpp_cuda_glsl_hlsl_spirv`
> CPP, CUDA, GLSL, HLSL, and SPIRV code-gen targets
+`cpp_cuda_glsl_hlsl_spirv_wgsl`
+> CPP, CUDA, GLSL, HLSL, SPIRV and WGSL code-gen targets
+
`cpp_cuda_glsl_hlsl_metal_spirv`
> CPP, CUDA, GLSL, HLSL, Metal and SPIRV code-gen targets
+`cpp_cuda_glsl_hlsl_metal_spirv_wgsl`
+> CPP, CUDA, GLSL, HLSL, Metal, SPIRV and WGSL code-gen targets
+
`cpp_cuda_hlsl`
> CPP, CUDA, and HLSL code-gen targets
@@ -708,9 +717,15 @@ Compound Capabilities
`cpp_glsl_hlsl_spirv`
> CPP, GLSL, HLSL, and SPIRV code-gen targets
+`cpp_glsl_hlsl_spirv_wgsl`
+> CPP, GLSL, HLSL, SPIRV and WGSL code-gen targets
+
`cpp_glsl_hlsl_metal_spirv`
> CPP, GLSL, HLSL, Metal, and SPIRV code-gen targets
+`cpp_glsl_hlsl_metal_spirv_wgsl`
+> CPP, GLSL, HLSL, Metal, SPIRV and WGSL code-gen targets
+
`cpp_hlsl`
> CPP, and HLSL code-gen targets
@@ -726,12 +741,18 @@ Compound Capabilities
`cuda_glsl_hlsl_metal_spirv`
> CUDA, GLSL, HLSL, Metal, and SPIRV code-gen targets
+`cuda_glsl_hlsl_metal_spirv_wgsl`
+> CUDA, GLSL, HLSL, Metal, SPIRV and WGSL code-gen targets
+
`cuda_glsl_spirv`
> CUDA, GLSL, and SPIRV code-gen targets
`cuda_glsl_metal_spirv`
> CUDA, GLSL, Metal, and SPIRV code-gen targets
+`cuda_glsl_metal_spirv_wgsl`
+> CUDA, GLSL, Metal, SPIRV and WGSL code-gen targets
+
`cuda_hlsl`
> CUDA, and HLSL code-gen targets
@@ -741,12 +762,21 @@ Compound Capabilities
`glsl_hlsl_spirv`
> GLSL, HLSL, and SPIRV code-gen targets
+`glsl_hlsl_spirv_wgsl`
+> GLSL, HLSL, SPIRV and WGSL code-gen targets
+
`glsl_hlsl_metal_spirv`
> GLSL, HLSL, Metal, and SPIRV code-gen targets
+`glsl_hlsl_metal_spirv_wgsl`
+> GLSL, HLSL, Metal, SPIRV and WGSL code-gen targets
+
`glsl_metal_spirv`
> GLSL, Metal, and SPIRV code-gen targets
+`glsl_metal_spirv_wgsl`
+> GLSL, Metal, SPIRV and WGSL code-gen targets
+
`glsl_spirv`
> GLSL, and SPIRV code-gen targets
diff --git a/source/slang-wasm/slang-wasm.cpp b/source/slang-wasm/slang-wasm.cpp
index c2cbe66b6..ee64f0e9b 100644
--- a/source/slang-wasm/slang-wasm.cpp
+++ b/source/slang-wasm/slang-wasm.cpp
@@ -45,10 +45,9 @@ Session* GlobalSession::createSession()
SessionDesc sessionDesc = {};
sessionDesc.structureSize = sizeof(sessionDesc);
constexpr SlangInt targetCount = 1;
- TargetDesc targets[targetCount] = {
- {.structureSize = sizeof(TargetDesc), .format = SLANG_WGSL}
- };
- sessionDesc.targets = targets;
+ TargetDesc target = {};
+ target.format = SLANG_WGSL;
+ sessionDesc.targets = &target;
sessionDesc.targetCount = targetCount;
SlangResult result = m_interface->createSession(sessionDesc, &session);
if (result != SLANG_OK)
diff --git a/source/slang/CMakeLists.txt b/source/slang/CMakeLists.txt
index cf12e6c24..8e3be2069 100644
--- a/source/slang/CMakeLists.txt
+++ b/source/slang/CMakeLists.txt
@@ -20,7 +20,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E make_directory ${SLANG_CAPABILITY_OUTPUT_DIR}
COMMAND
slang-capability-generator ${SLANG_CAPABILITY_SOURCE} --target-directory
- ${SLANG_CAPABILITY_OUTPUT_DIR}
+ ${SLANG_CAPABILITY_OUTPUT_DIR} --doc "${slang_SOURCE_DIR}/docs/user-guide/a3-02-reference-capability-atoms.md"
DEPENDS ${SLANG_CAPABILITY_SOURCE} slang-capability-generator
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
VERBATIM
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 5ca1baeec..781a3a237 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -5919,7 +5919,7 @@ namespace Slang
intrinsicOpModifier->op = kIROp_IntCast;
break;
default:
- SLANG_ASSERT("unknown builtin requirement kind.");
+ SLANG_UNEXPECTED("unknown builtin requirement kind.");
}
synFunc->loc = context->parentDecl->closingSourceLoc;
synFunc->nameAndLoc.loc = synFunc->loc;
diff --git a/source/slangc/main.cpp b/source/slangc/main.cpp
index 6e76e2f93..c7cca428b 100644
--- a/source/slangc/main.cpp
+++ b/source/slangc/main.cpp
@@ -104,7 +104,7 @@ SLANG_TEST_TOOL_API SlangResult innerMain(StdWriters* stdWriters, slang::IGlobal
SlangResult res = _compile(compileRequest, argc, argv);
// Now that we are done, clean up after ourselves
spDestroyCompileRequest(compileRequest);
-
+
return res;
}
diff --git a/tools/slang-capability-generator/capability-generator-main.cpp b/tools/slang-capability-generator/capability-generator-main.cpp
index 674aca7fd..0b2540599 100644
--- a/tools/slang-capability-generator/capability-generator-main.cpp
+++ b/tools/slang-capability-generator/capability-generator-main.cpp
@@ -1267,11 +1267,13 @@ int main(int argc, const char* const* argv)
argc >= 1 ? argv[0] : "slang-capabilities-generator");
return 1;
}
- String targetDir;
+ String targetDir, outDocPath;
for (int i = 0; i < argc - 1; i++)
{
if (strcmp(argv[i], "--target-directory") == 0)
targetDir = argv[i + 1];
+ if (strcmp(argv[i], "--doc") == 0)
+ outDocPath = argv[i + 1];
}
String inPath = argv[1];
@@ -1299,7 +1301,6 @@ int main(int argc, const char* const* argv)
return 1;
}
- auto outDocPath = Path::combine(targetDir, "../../docs/user-guide/a3-02-reference-capability-atoms.md");
if (!File::exists(outDocPath))
{
sink.diagnose(SourceLoc(), Diagnostics::couldNotFindValidDocumentationOutputPath, outDocPath);
diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp
index d84e594e8..c54ee19f3 100644
--- a/tools/slang-generate/main.cpp
+++ b/tools/slang-generate/main.cpp
@@ -921,6 +921,11 @@ int main(
FILE* outputStream;
fopen_s(&outputStream, outputPath.getBuffer(), "w");
+ if (!outputStream)
+ {
+ fprintf(stderr, "unable to open file for writing: %s.\n", outputPath.getBuffer());
+ exit(1);
+ }
emitTemplateNodes(sourceFile, outputStream, node);