summaryrefslogtreecommitdiff
path: root/source/slang/slang-options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-options.cpp')
-rw-r--r--source/slang/slang-options.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 85602b744..216040f98 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -99,6 +99,9 @@ enum class OptionKind
GLSLForceScalarLayout,
EnableEffectAnnotations,
+
+ EmitSpirvViaGLSL,
+ EmitSpirvDirectly,
// Downstream
@@ -131,7 +134,6 @@ enum class OptionKind
// Experimental
- EmitSpirvDirectly,
FileSystem,
Heterogeneous,
NoMangle,
@@ -506,6 +508,17 @@ void initCommandOptions(CommandOptions& options)
{ OptionKind::EnableEffectAnnotations,
"-enable-effect-annotations", nullptr,
"Enables support for legacy effect annotation syntax."},
+#if defined(SLANG_CONFIG_DEFAULT_SPIRV_DIRECT)
+ { OptionKind::EmitSpirvViaGLSL, "-emit-spirv-via-glsl", nullptr,
+ "Generate SPIR-V output by compiling generated GLSL with glslang" },
+ { OptionKind::EmitSpirvDirectly, "-emit-spirv-directly", nullptr,
+ "Generate SPIR-V output direclty (default)" },
+#else
+ { OptionKind::EmitSpirvViaGLSL, "-emit-spirv-via-glsl", nullptr,
+ "Generate SPIR-V output by compiling generated GLSL with glslang (default)" },
+ { OptionKind::EmitSpirvDirectly, "-emit-spirv-directly", nullptr,
+ "Generate SPIR-V output direclty rather than by compiling generated GLSL with glslang" },
+#endif
};
_addOptions(makeConstArrayView(targetOpts), options);
@@ -583,9 +596,6 @@ void initCommandOptions(CommandOptions& options)
const Option experimentalOpts[] =
{
- { OptionKind::EmitSpirvDirectly, "-emit-spirv-directly", nullptr,
- "Generate SPIR-V output directly (otherwise through "
- "GLSL and using the glslang compiler)"},
{ OptionKind::FileSystem, "-file-system", "-file-system <file-system-type>",
"Set the filesystem hook to use for a compile request."},
{ OptionKind::Heterogeneous, "-heterogeneous", nullptr, "Output heterogeneity-related code." },
@@ -726,7 +736,7 @@ struct OptionsParser
{
CodeGenTarget format = CodeGenTarget::Unknown;
ProfileVersion profileVersion = ProfileVersion::Unknown;
- SlangTargetFlags targetFlags = 0;
+ SlangTargetFlags targetFlags = kDefaultTargetFlags;
int targetID = -1;
FloatingPointMode floatingPointMode = FloatingPointMode::Default;
bool forceGLSLScalarLayout = false;
@@ -2280,7 +2290,16 @@ SlangResult OptionsParser::_parse(
// We retun an error so after this has successfully passed, we quit
return SLANG_FAIL;
}
- case OptionKind::EmitSpirvDirectly: getCurrentTarget()->targetFlags |= SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY; break;
+ case OptionKind::EmitSpirvViaGLSL:
+ {
+ getCurrentTarget()->targetFlags &= ~SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
+ }
+ break;
+ case OptionKind::EmitSpirvDirectly:
+ {
+ getCurrentTarget()->targetFlags |= SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY;
+ }
+ break;
case OptionKind::DefaultDownstreamCompiler:
{