summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-05-03 18:02:31 -0700
committerGitHub <noreply@github.com>2024-05-03 18:02:31 -0700
commit59903ef7e4ddd8885f71567bf0fc85527a88fffc (patch)
tree700a177860d24610780390b35277aa8ff5c47947 /source/slang
parent54153a3681c7c6ef86c6f7a864719d32a1934240 (diff)
Add host shared library target. (#4098)
* Add host shared library target. * Attempt fix. * Fix warnings. * try fix. * Fix test. * Fix.
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-ast-dump.cpp1
-rw-r--r--source/slang/slang-check-stmt.cpp2
-rw-r--r--source/slang/slang-compiler.cpp14
-rwxr-xr-xsource/slang/slang-compiler.h1
-rw-r--r--source/slang/slang-emit-cpp.cpp5
-rw-r--r--source/slang/slang-emit-glsl.cpp2
-rw-r--r--source/slang/slang-emit-spirv.cpp2
-rw-r--r--source/slang/slang-ir-layout.cpp1
-rw-r--r--source/slang/slang-ir-util.cpp1
-rw-r--r--source/slang/slang-options.cpp1
-rw-r--r--source/slang/slang-type-layout.cpp2
-rw-r--r--source/slang/slang.cpp2
12 files changed, 30 insertions, 4 deletions
diff --git a/source/slang/slang-ast-dump.cpp b/source/slang/slang-ast-dump.cpp
index 0019b2130..0986d7284 100644
--- a/source/slang/slang-ast-dump.cpp
+++ b/source/slang/slang-ast-dump.cpp
@@ -677,6 +677,7 @@ struct ASTDumpContext
break;
case SPIRVAsmOperand::RayCallableFromLocation:
m_writer->emit("__rayCallableFromLocation");
+ break;
case SPIRVAsmOperand::BuiltinVar:
m_writer->emit("builtin");
break;
diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp
index f7b085579..2af8f7d08 100644
--- a/source/slang/slang-check-stmt.cpp
+++ b/source/slang/slang-check-stmt.cpp
@@ -267,7 +267,7 @@ namespace Slang
}
}
}
- else if (auto defaultStmt = as<DefaultStmt>(sStmt))
+ else if (as<DefaultStmt>(sStmt))
{
// check that there is at most one `default` clause
if (hasDefaultStmt)
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 1f1bed902..b2b765c0e 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -539,6 +539,7 @@ namespace Slang
case CodeGenTarget::ShaderSharedLibrary:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::HostHostCallable:
+ case CodeGenTarget::HostSharedLibrary:
{
// We need some C/C++ compiler
return PassThroughMode::GenericCCpp;
@@ -955,6 +956,7 @@ namespace Slang
}
case CodeGenTarget::HostHostCallable:
case CodeGenTarget::HostExecutable:
+ case CodeGenTarget::HostSharedLibrary:
{
return CodeGenTarget::HostCPPSource;
}
@@ -1279,8 +1281,14 @@ namespace Slang
// Set the source type
options.sourceLanguage = SlangSourceLanguage(sourceLanguage);
- // Disable exceptions and security checks
- options.flags &= ~(CompileOptions::Flag::EnableExceptionHandling | CompileOptions::Flag::EnableSecurityChecks);
+ switch (target)
+ {
+ case CodeGenTarget::ShaderHostCallable:
+ case CodeGenTarget::ShaderSharedLibrary:
+ // Disable exceptions and security checks
+ options.flags &= ~(CompileOptions::Flag::EnableExceptionHandling | CompileOptions::Flag::EnableSecurityChecks);
+ break;
+ }
Profile profile;
@@ -1586,6 +1594,7 @@ namespace Slang
case CodeGenTarget::ShaderSharedLibrary:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::HostHostCallable:
+ case CodeGenTarget::HostSharedLibrary:
SLANG_RETURN_ON_FAIL(emitWithDownstreamForEntryPoints(outArtifact));
return SLANG_OK;
@@ -1617,6 +1626,7 @@ namespace Slang
case CodeGenTarget::ShaderHostCallable:
case CodeGenTarget::ShaderSharedLibrary:
case CodeGenTarget::HostExecutable:
+ case CodeGenTarget::HostSharedLibrary:
{
SLANG_RETURN_ON_FAIL(_emitEntryPoints(outArtifact));
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 2711da3c9..fc97a2f47 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -85,6 +85,7 @@ namespace Slang
PyTorchCppBinding = SLANG_CPP_PYTORCH_BINDING,
HostCPPSource = SLANG_HOST_CPP_SOURCE,
HostExecutable = SLANG_HOST_EXECUTABLE,
+ HostSharedLibrary = SLANG_HOST_SHARED_LIBRARY,
ShaderSharedLibrary = SLANG_SHADER_SHARED_LIBRARY,
ShaderHostCallable = SLANG_SHADER_HOST_CALLABLE,
CUDASource = SLANG_CUDA_SOURCE,
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 2b1f6ad81..7e327cab4 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -329,6 +329,7 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S
out << ">";
return SLANG_OK;
}
+ return SLANG_FAIL;
}
case kIROp_IntLit:
{
@@ -1728,6 +1729,10 @@ void CPPSourceEmitter::emitPreModuleImpl()
m_writer->emit("using namespace SLANG_PRELUDE_NAMESPACE;\n");
m_writer->emit("#endif\n\n");
}
+ else if (m_target == CodeGenTarget::HostCPPSource)
+ {
+ m_writer->emit("namespace Slang{ inline void handleSignal(SignalType, char const*) {} }\n");
+ }
Super::emitPreModuleImpl();
}
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index d768cff97..f9fa90d2f 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -2190,7 +2190,7 @@ void GLSLSourceEmitter::handleRequiredCapabilitiesImpl(IRInst* inst)
{
_requireGLSLExtension(requireGLSLExt->getExtensionName());
}
- else if (auto requireComputeDerivative = as<IRRequireComputeDerivative>(childInst))
+ else if (const auto requireComputeDerivative = as<IRRequireComputeDerivative>(childInst))
{
// only allowed 1 of derivative_group_quadsNV or derivative_group_linearNV
if (m_entryPointStage != Stage::Compute
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 106248ef8..a7cdfc8a3 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -1957,6 +1957,7 @@ struct SPIRVEmitContext
format = SpvImageFormatRgba8;
break;
}
+ break;
case kIROp_SNormAttr:
switch (vectorSize)
{
@@ -1973,6 +1974,7 @@ struct SPIRVEmitContext
format = SpvImageFormatRgba8Snorm;
break;
}
+ break;
}
}
}
diff --git a/source/slang/slang-ir-layout.cpp b/source/slang/slang-ir-layout.cpp
index 3ac022f68..f35fa6750 100644
--- a/source/slang/slang-ir-layout.cpp
+++ b/source/slang/slang-ir-layout.cpp
@@ -96,6 +96,7 @@ static Result _calcSizeAndAlignment(
case CodeGenTarget::HostCPPSource:
case CodeGenTarget::HostHostCallable:
case CodeGenTarget::HostExecutable:
+ case CodeGenTarget::HostSharedLibrary:
kPointerSize = (int)sizeof(void*);
break;
}
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
index 1fccf3e27..51b8344f6 100644
--- a/source/slang/slang-ir-util.cpp
+++ b/source/slang/slang-ir-util.cpp
@@ -537,6 +537,7 @@ void getTypeNameHint(StringBuilder& sb, IRInst* type)
break;
case kIROp_GLSLAtomicUintType:
sb << "AtomicCounter";
+ break;
case kIROp_RaytracingAccelerationStructureType:
sb << "RayTracingAccelerationStructure";
break;
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 805ea0fff..b6fcafb61 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -2824,6 +2824,7 @@ SlangResult OptionsParser::_parse(
case CodeGenTarget::ShaderHostCallable:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::ShaderSharedLibrary:
+ case CodeGenTarget::HostSharedLibrary:
case CodeGenTarget::PyTorchCppBinding:
case CodeGenTarget::DXIL:
case CodeGenTarget::MetalLib:
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index d81cc92cd..83901ecc4 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -1756,6 +1756,7 @@ LayoutRulesFamilyImpl* getDefaultLayoutRulesFamilyForTarget(TargetRequest* targe
case CodeGenTarget::HostHostCallable:
case CodeGenTarget::ShaderHostCallable:
case CodeGenTarget::HostExecutable:
+ case CodeGenTarget::HostSharedLibrary:
case CodeGenTarget::ShaderSharedLibrary:
case CodeGenTarget::CPPSource:
case CodeGenTarget::CSource:
@@ -2057,6 +2058,7 @@ SourceLanguage getIntermediateSourceLanguageForTarget(TargetProgram* targetProgr
return SourceLanguage::C;
}
case CodeGenTarget::ShaderSharedLibrary:
+ case CodeGenTarget::HostSharedLibrary:
case CodeGenTarget::ObjectCode:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::HostHostCallable:
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 9b612b340..45a6933de 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -246,6 +246,7 @@ void Session::_initCodeGenTransitionMap()
// is available. We prefer LLVM if that's available. If it's not we can use generic C/C++ compiler
map.addTransition(source, CodeGenTarget::ShaderSharedLibrary, PassThroughMode::GenericCCpp);
+ map.addTransition(source, CodeGenTarget::HostSharedLibrary, PassThroughMode::GenericCCpp);
map.addTransition(source, CodeGenTarget::HostExecutable, PassThroughMode::GenericCCpp);
map.addTransition(source, CodeGenTarget::ObjectCode, PassThroughMode::GenericCCpp);
}
@@ -1709,6 +1710,7 @@ CapabilitySet TargetRequest::getTargetCaps()
case CodeGenTarget::PyTorchCppBinding:
case CodeGenTarget::HostExecutable:
case CodeGenTarget::ShaderSharedLibrary:
+ case CodeGenTarget::HostSharedLibrary:
case CodeGenTarget::HostHostCallable:
case CodeGenTarget::ShaderHostCallable:
atoms.add(CapabilityName::cpp);