From 313677160a186efebf83fab4df7d08dd119a5cd2 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Thu, 5 Sep 2024 14:59:28 -0400 Subject: Initial -embed-spirv support (#4974) * Initial -embed-spirv support Add support for SPIR-V precompilation using the framework established for DXIL. Work on #4883 * SLANG_UNUSED * Add linkage attributes to exported spirv functions * Combine DXIL and SPIRV paths * Whitespace fix * Merge remaining precompiled spirv/dxil paths * Change inst accessors to return codegentarget * Add unit test for precompiled spirv --------- Co-authored-by: Yong He --- source/slang/slang-options.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index f12a66790..c02a00957 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -354,8 +354,6 @@ void initCommandOptions(CommandOptions& options) { OptionKind::DisableShortCircuit, "-disable-short-circuit", nullptr, "Disable short-circuiting for \"&&\" and \"||\" operations" }, { OptionKind::UnscopedEnum, "-unscoped-enum", nullptr, "Treat enums types as unscoped by default."}, { OptionKind::PreserveParameters, "-preserve-params", nullptr, "Preserve all resource parameters in the output code, even if they are not used by the shader."}, - { OptionKind::EmbedDXIL, "-embed-dxil", nullptr, - "Embed DXIL into emitted slang-modules for faster linking" }, }; _addOptions(makeConstArrayView(generalOpts), options); @@ -431,6 +429,7 @@ void initCommandOptions(CommandOptions& options) "A path to a specific spirv.core.grammar.json to use when generating SPIR-V output" }, { OptionKind::IncompleteLibrary, "-incomplete-library", nullptr, "Allow generating code from incomplete libraries with unresolved external functions" }, + { OptionKind::EmbedDownstreamIR, "-embed-downstream-ir", nullptr, "Embed downstream IR into emitted slang IR" }, }; _addOptions(makeConstArrayView(targetOpts), options); @@ -1931,7 +1930,11 @@ SlangResult OptionsParser::_parse( linkage->m_optionSet.set(optionKind, compressionType); break; } - case OptionKind::EmbedDXIL: m_compileRequest->setEmbedDXIL(true); break; + case OptionKind::EmbedDownstreamIR: + { + getCurrentTarget()->optionSet.add(CompilerOptionName::EmbedDownstreamIR, true); + break; + } case OptionKind::Target: { CommandLineArg name; @@ -2778,6 +2781,12 @@ SlangResult OptionsParser::_parse( { m_compileRequest->setTargetGenerateWholeProgram(targetID, true); } + + if (rawTarget.optionSet.getBoolOption(CompilerOptionName::EmbedDownstreamIR)) + { + m_compileRequest->setTargetEmbedDownstreamIR(targetID, true); + } + } // Next we need to sort out the output files specified with `-o`, and -- cgit v1.2.3