diff options
| author | cheneym2 <acheney@nvidia.com> | 2024-08-30 02:23:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-29 23:23:26 -0700 |
| commit | ddf4a323be5ae4e59dce742f618dbbdee4ed28d8 (patch) | |
| tree | fc391cb7dc902536280d5fa044292131614db163 /source/slang/slang-options.cpp | |
| parent | 87d3d4f73a2b3af3ec00f221350864602d12321d (diff) | |
Support mixture of precompiled and non-precompiled modules (#4860)
* Support mixture of precompiled and non-precompiled modules
This changes the implementation of precompile DXIL modules to
accept combinations of modules with precompiled DXIL, ones without,
and ones with a mixture of precompiled DXIL and Slang IR.
During precompilation, module IR is analyzed to find public functions
which appear to be capable of being compiled as HLSL, and those
functions are given a HLSLExport decoration, ensuring they are emitted
as HLSL and preserved in the precompiled DXIL blob. The IR for those
functions is then tagged with a new decoration AvailableInDXIL, which
marks that their implementation is present in the embedded DXIL blob.
The DXIL blob is attached to the IR as before, inside a EmbeddedDXIL
BlobLit instruction.
The logic that determines whether or not functions should be
precompiled to DXIL is a placeholder at this point, returning true
always. A subsequent change will add selection criteria.
During module linking, the full module IR is available, as well
as the optional EmbeddedDXIL blob. The IR for functions implemented
by the blob are tagged with AvailableInDXIL in the module IR.
After linking the IR for all modules to program level IR, the IR for
the functions marked AvailableInDXIL are deleted from the linked IR,
prior to emitting HLSL and compiling linking the result.
This change also changes the point of time when the module IR is
checked for EmbeddedDXIL blobs. Instead of happening at load time
as before, it happens during immediately before final linking, meaning
that the blob does not need to be independently stored with the module
separate from the IR as was done previously.
Work on #4792
* Clean up debug prints
* Call isSimpleHLSLDataType stub
* Address feedback on precompiled dxil support
Allow for IR filtering both before and after linking.
Only mark AvailableInDXIL those functions which pass
both filtering stages. Functions are corrlated using
mangled function names.
Rather than delete functions entirely when linking with
libraries that include precompiled DXIL, instead convert
the IR function definitions to declarations by gutting
them, removing child blocks.
* Use artifact metadata and name list instead of linkedir hack
* Use String instead of UnownedStringSlice
* Update tests
* Renaming
* Minor edits
* Don't fully remove functions post-link
* Unexport before collecting metadata
Diffstat (limited to 'source/slang/slang-options.cpp')
| -rw-r--r-- | source/slang/slang-options.cpp | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 12b32998f..cf0dd2f20 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -702,8 +702,6 @@ struct OptionsParser void setProfile(RawTarget* rawTarget, Profile profile); void addCapabilityAtom(RawTarget* rawTarget, CapabilityName atom); - SlangResult addEmbeddedLibrary(const CodeGenTarget format, CompilerOptionName option); - void setFloatingPointMode(RawTarget* rawTarget, FloatingPointMode mode); SlangResult parse( @@ -1640,23 +1638,6 @@ SlangResult OptionsParser::_parseProfile(const CommandLineArg& arg) return SLANG_OK; } -// Creates a target of the specified type whose output will be embedded as IR metadata -SlangResult OptionsParser::addEmbeddedLibrary(const CodeGenTarget format, CompilerOptionName option) -{ - RawTarget rawTarget; - rawTarget.format = format; - // Silently allow redundant targets if it is the same as the last specified target. - if (m_rawTargets.getCount() == 0 || m_rawTargets.getLast().format != rawTarget.format) - { - m_rawTargets.add(rawTarget); - } - - getCurrentTarget()->optionSet.add(option, true); - getCurrentTarget()->optionSet.add(CompilerOptionName::GenerateWholeProgram, true); - - return SLANG_OK; -} - SlangResult OptionsParser::_parse( int argc, char const* const* argv) @@ -1948,7 +1929,7 @@ SlangResult OptionsParser::_parse( linkage->m_optionSet.set(optionKind, compressionType); break; } - case OptionKind::EmbedDXIL: SLANG_RETURN_ON_FAIL(addEmbeddedLibrary(CodeGenTarget::DXIL, CompilerOptionName::EmbedDXIL)); break; + case OptionKind::EmbedDXIL: m_compileRequest->setEmbedDXIL(true); break; case OptionKind::Target: { CommandLineArg name; @@ -2795,11 +2776,6 @@ SlangResult OptionsParser::_parse( { m_compileRequest->setTargetGenerateWholeProgram(targetID, true); } - - if (rawTarget.optionSet.getBoolOption(CompilerOptionName::EmbedDXIL)) - { - m_compileRequest->setTargetEmbedDXIL(targetID, true); - } } // Next we need to sort out the output files specified with `-o`, and |
