summaryrefslogtreecommitdiff
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.cpp54
1 files changed, 34 insertions, 20 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 1b20a869d..80899e69e 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1193,24 +1193,46 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
// Disable exceptions and security checks
options.flags &= ~(CompileOptions::Flag::EnableExceptionHandling | CompileOptions::Flag::EnableSecurityChecks);
+ Profile profile;
+
if (compilerType == PassThroughMode::Fxc ||
compilerType == PassThroughMode::Dxc ||
compilerType == PassThroughMode::Glslang)
{
- auto entryPointIndex = getSingleEntryPointIndex();
+ const auto entryPointIndices = getEntryPointIndices();
+ auto targetReq = getTargetReq();
- auto entryPoint = getEntryPoint(entryPointIndex);
- auto profile = getEffectiveProfile(entryPoint, getTargetReq());
+ const auto entryPointIndicesCount = entryPointIndices.getCount();
+
+ if (entryPointIndicesCount == 0 && compilerType == PassThroughMode::Dxc)
+ {
+ // Can support no entry points on DXC because we can build libraries
+ profile = targetReq->getTargetProfile();
+ }
+ else if (entryPointIndicesCount == 1)
+ {
+ // All support a single entry point
+ const Index entryPointIndex = entryPointIndices[0];
- options.stage = SlangStage(profile.getStage());
+ auto entryPoint = getEntryPoint(entryPointIndex);
+ profile = getEffectiveProfile(entryPoint, targetReq);
- // Set the entry point name
- options.entryPointName = getText(entryPoint->getName());
- auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex);
- if (entryPointNameOverride.getLength() != 0)
+ options.entryPointName = getText(entryPoint->getName());
+ auto entryPointNameOverride = getProgram()->getEntryPointNameOverride(entryPointIndex);
+ if (entryPointNameOverride.getLength() != 0)
+ {
+ options.entryPointName = entryPointNameOverride;
+ }
+ }
+ else
{
- options.entryPointName = entryPointNameOverride;
+ // We only support a single entry point on this target
+ SLANG_ASSERT(!"Can only compile with a single entry point on this target");
+ return SLANG_FAIL;
}
+
+ options.stage = SlangStage(profile.getStage());
+
if (compilerType == PassThroughMode::Dxc)
{
// We will enable the flag to generate proper code for 16 - bit types
@@ -1229,20 +1251,12 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
options.flags |= CompileOptions::Flag::EnableFloat16;
}
- // Only set the profile if the stage is set
- if (options.stage != SLANG_STAGE_NONE)
- {
- options.profileName = GetHLSLProfileName(profile);
- }
-
// Set the matrix layout
options.matrixLayout = getTargetReq()->getDefaultMatrixLayoutMode();
}
- else if (compilerType == PassThroughMode::Fxc)
- {
- // Set the profile
- options.profileName = GetHLSLProfileName(profile);
- }
+
+ // Set the profile
+ options.profileName = GetHLSLProfileName(profile);
}
// If we aren't using LLVM 'host callable', we want downstream compile to produce a shared library