summaryrefslogtreecommitdiffstats
path: root/tests/library
diff options
context:
space:
mode:
authorcheneym2 <acheney@nvidia.com>2024-08-05 15:37:46 -0400
committerGitHub <noreply@github.com>2024-08-05 15:37:46 -0400
commitd72f9f6f72a7a74d7466a1e301e1853fea5daa25 (patch)
tree4ae77e2dd622779b64d063d1f50fc7af8c13a94a /tests/library
parentd63f5e20f1edf7c51ca5c456baceb9eb9a84c95b (diff)
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 "<binary blob>". * 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
Diffstat (limited to 'tests/library')
-rw-r--r--tests/library/precompiled-dxil.slang24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/library/precompiled-dxil.slang b/tests/library/precompiled-dxil.slang
new file mode 100644
index 000000000..19f67b075
--- /dev/null
+++ b/tests/library/precompiled-dxil.slang
@@ -0,0 +1,24 @@
+// precompiled-dxil.slang
+
+// A test that uses slang-modules with embedded precompiled DXIL.
+// The test compiles both library slang (export-library.slang) and entrypoint slang (this file) to two slang-modules, each with -embed-dxil options.
+// The result is two slang-modules that are then linked together in a third slangc invocation.
+// Internally, slang does not use the IR in the modules to link, but rather their embedded DXIL.
+// The test passes if there is no errror thrown.
+// TODO: Check if final linkage used only the precompiled dxil.
+
+//TEST(windows):COMPILE: tests/library/export-library.slang -o tests/library/export-library.slang-module -embed-dxil -profile lib_6_6 -incomplete-library
+//TEST(windows):COMPILE: tests/library/precompiled-dxil.slang -o tests/library/precompiled-dxil.slang-module -embed-dxil -profile lib_6_6 -incomplete-library
+//TEST(windows):COMPILE: tests/library/export-library.slang-module tests/library/precompiled-dxil.slang-module -target dxil -entry computeMain -profile cs_6_6 -o tests/library/linked.dxil
+
+extern int foo(int a);
+
+RWStructuredBuffer<int> outputBuffer;
+
+[shader("compute")]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = (int)dispatchThreadID.x;
+
+ outputBuffer[index] = foo(index);
+}