summaryrefslogtreecommitdiffstats
path: root/source/slang/compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/compiler.cpp')
-rw-r--r--source/slang/compiler.cpp95
1 files changed, 71 insertions, 24 deletions
diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp
index f16ad06b7..ea1b650a8 100644
--- a/source/slang/compiler.cpp
+++ b/source/slang/compiler.cpp
@@ -139,6 +139,19 @@ namespace Slang
return Profile::Unknown;
}
+ char const* Profile::getName()
+ {
+ switch( raw )
+ {
+ default:
+ return "unknown";
+
+ #define PROFILE(TAG, NAME, STAGE, VERSION) case Profile::TAG: return #NAME;
+ #define PROFILE_ALIAS(TAG, DEF, NAME) /* empty */
+ #include "profile-defs.h"
+ }
+ }
+
Stage findStageByName(String const& name)
{
static const struct
@@ -268,7 +281,7 @@ namespace Slang
}
}
- char const* GetHLSLProfileName(Profile profile)
+ String GetHLSLProfileName(Profile profile)
{
switch( profile.getFamily() )
{
@@ -285,15 +298,56 @@ namespace Slang
break;
}
- switch(profile.raw)
+ char const* stagePrefix = nullptr;
+ switch( profile.GetStage() )
{
- #define PROFILE(TAG, NAME, STAGE, VERSION) case Profile::TAG: return #NAME;
- #include "profile-defs.h"
+ default:
+ return "unknown";
+
+ #define CASE(NAME, PREFIX) case Stage::NAME: stagePrefix = #PREFIX; break
+ CASE(Vertex, vs);
+ CASE(Hull, hs);
+ CASE(Domain, ds);
+ CASE(Geometry, gs);
+ CASE(Fragment, ps);
+ CASE(Compute, cs);
+
+ // Note: dxc requires a `lib` target for all
+ // ray tracing stages.
+ CASE(RayGeneration, lib);
+ CASE(Intersection, lib);
+ CASE(AnyHit, lib);
+ CASE(ClosestHit, lib);
+ CASE(Miss, lib);
+ CASE(Callable, lib);
+ #undef CASE
+ }
+
+ char const* versionSuffix = nullptr;
+ switch(profile.GetVersion())
+ {
+ #define CASE(TAG, SUFFIX) case ProfileVersion::TAG: versionSuffix = #SUFFIX; break
+ CASE(DX_4_0, _4_0);
+ CASE(DX_4_0_Level_9_0, _4_0_level_9_0);
+ CASE(DX_4_0_Level_9_1, _4_0_level_9_1);
+ CASE(DX_4_0_Level_9_3, _4_0_level_9_3);
+ CASE(DX_4_1, _4_1);
+ CASE(DX_5_0, _5_0);
+ CASE(DX_5_1, _5_1);
+ CASE(DX_6_0, _6_0);
+ CASE(DX_6_1, _6_1);
+ CASE(DX_6_2, _6_2);
+ CASE(DX_6_3, _6_3);
+ #undef CASE
default:
- // TODO: emit an error here!
return "unknown";
}
+
+ String result;
+ result.append(stagePrefix);
+ result.append(versionSuffix);
+ return result;
}
#if SLANG_ENABLE_DXBC_SUPPORT
@@ -375,7 +429,7 @@ namespace Slang
dxMacros,
nullptr,
getText(entryPoint->name).begin(),
- GetHLSLProfileName(profile),
+ GetHLSLProfileName(profile).Buffer(),
0,
0,
&codeBlob,
@@ -787,13 +841,12 @@ String dissassembleDXILUsingDXC(
}
static void writeEntryPointResultToFile(
- EntryPointRequest* entryPoint,
- TargetRequest* targetReq,
- UInt entryPointIndex)
+ EntryPointRequest* entryPoint,
+ String const& outputPath,
+ CompileResult const& result)
{
auto compileRequest = entryPoint->compileRequest;
- auto outputPath = entryPoint->outputPath;
- auto result = targetReq->entryPointResults[entryPointIndex];
+
switch (result.format)
{
case ResultFormat::Text:
@@ -837,12 +890,11 @@ String dissassembleDXILUsingDXC(
}
static void writeEntryPointResultToStandardOutput(
- EntryPointRequest* entryPoint,
- TargetRequest* targetReq,
- UInt entryPointIndex)
+ EntryPointRequest* entryPoint,
+ TargetRequest* targetReq,
+ CompileResult const& result)
{
auto compileRequest = entryPoint->compileRequest;
- auto& result = targetReq->entryPointResults[entryPointIndex];
switch (result.format)
{
@@ -924,28 +976,23 @@ String dissassembleDXILUsingDXC(
TargetRequest* targetReq,
UInt entryPointIndex)
{
+ auto outputPath = targetReq->entryPointOutputPaths[entryPointIndex];
auto& result = targetReq->entryPointResults[entryPointIndex];
// Skip the case with no output
if (result.format == ResultFormat::None)
return;
- if (entryPoint->outputPath.Length())
+ if (outputPath.Length())
{
- writeEntryPointResultToFile(entryPoint, targetReq, entryPointIndex);
+ writeEntryPointResultToFile(entryPoint, outputPath, result);
}
else
{
- writeEntryPointResultToStandardOutput(entryPoint, targetReq, entryPointIndex);
+ writeEntryPointResultToStandardOutput(entryPoint, targetReq, result);
}
}
- void emitEntryPoints(
- TargetRequest* /*targetReq*/)
- {
-
- }
-
void generateOutputForTarget(
TargetRequest* targetReq)
{