From d72f9f6f72a7a74d7466a1e301e1853fea5daa25 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Mon, 5 Aug 2024 15:37:46 -0400 Subject: Initial support for precompiled DXIL in slang-modules (#4755) * Add embedded precompiled binary IR ops Add IR operations to embed precompiled DXIL or SPIR-V blobs into IR. Adds a BlobLit literal that is mostly identical to StringLit except for its inability to be displayed, e.g. in dumped IR. In the future, the blob might be dumped as hexadecimal, but for now it is summarized as "". * EmbeddedDXIL and SPIR-V options The options, '-embed-dxil' and '-embed-spirv' in slangc, will cause a target dxil or spirv to be compiled and stored in the translation unit IR when written to a slang-module. Subsequent changes actually implement the options. * Per-translation unit DXIL precompilation When -embed-dxil is specified, perform a precompilation to DXIL of each TU, linked only with stdlib. Embed the resulting DXIL for the TU in a IR op. Being part of IR, the precompiled DXIL can be serialized to disk in a slang-module. Upon loading slang-modules, the new IR op will be searched for and the precompiled DXIL blob is saved with the loaded Module. During linking, if all the Modules have precompiled blobs they will be sent to the downstream compile commands as libraries instead of source, skipping the downstream compilation, using DXC only for linking. Fixes Issue #4580 * Remove placeholder embedded SPIRV support Code was added only to sketch out how other precompiled bins will be supported. * Remove the rest of the SPIRV placeholder support * Fix warnings, test error on non-windows * Remove lib_6_6 hack, add dxil_lib capability * Allocate blob value from irmodule memarena * Add null check after memarena allocation * Restore the request->e2erequest code path for generatewholeprogram * Update capability handling, move EmbedDXIL enum to end to preserve abi * Remove lib_6_6 hack * Move ICompileRequest functions to end --- include/slang.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/slang.h b/include/slang.h index 25e364504..c68157759 100644 --- a/include/slang.h +++ b/include/slang.h @@ -970,6 +970,7 @@ extern "C" UseUpToDateBinaryModule, // bool, when set, will only load // precompiled modules if it is up-to-date with its source. + EmbedDXIL, // bool CountOf, }; @@ -4152,7 +4153,6 @@ namespace slang int targetIndex, SlangTargetFlags flags) = 0; - /*! @brief Set the floating point mode (e.g., precise or fast) to use a target. */ @@ -4704,6 +4704,13 @@ namespace slang // return a copy of internal profiling results, and if `shouldClear` is true, clear the internal profiling results before returning. virtual SLANG_NO_THROW SlangResult SLANG_MCALL getCompileTimeProfile(ISlangProfiler** compileTimeProfile, bool shouldClear) = 0; + virtual SLANG_NO_THROW void SLANG_MCALL setTargetGenerateWholeProgram( + int targetIndex, + bool value) = 0; + + virtual SLANG_NO_THROW void SLANG_MCALL setTargetEmbedDXIL( + int targetIndex, + bool value) = 0; }; #define SLANG_UUID_ICompileRequest ICompileRequest::getTypeGuid() -- cgit v1.2.3