From d939773a9127bccbbd22903eb5b5620ad7127d37 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 15 Apr 2022 15:46:45 -0400 Subject: DXIL library support and Artifact type (#2186) * #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments. --- tests/library/library-test.slang | 27 +++++++++++++++++++++++++++ tests/library/library.slang | 9 +++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/library/library-test.slang create mode 100644 tests/library/library.slang (limited to 'tests') diff --git a/tests/library/library-test.slang b/tests/library/library-test.slang new file mode 100644 index 000000000..06bb22961 --- /dev/null +++ b/tests/library/library-test.slang @@ -0,0 +1,27 @@ +// library-test.slang + +// A test to try out the basics of using libraries that can be linked (by downstream tools). +// (This is in contrast to Slang modules and Slangs own linkage mechanisms) + +// This didn't work for lib_6_2 when compiling via DXC (!). Even though it's stated elsewhere the feature is available from 6.1 + +//TEST:COMPILE: tests/library/library.slang -profile lib_6_3 -target dxil -o tests/library/library.dxil +//DISABLE_TEST:COMPILE: tests/library/library-test.slang -profile cs_6_3 tests/library/library.dxil -o tests/library/library-test.dxil + +// It seems that I can't just compile the source containing the entry point/stage with the library/s. +// Instead I have to compile all the parts with lib profile, and then link together at the end. + +//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -xslang -r -xslang tests/serialization/serialized-module.slang-module -shaderobj + +extern int foo(int a); + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = (int)dispatchThreadID.x; + + outputBuffer[index] = foo(index); +} diff --git a/tests/library/library.slang b/tests/library/library.slang new file mode 100644 index 000000000..a9e7e5e7a --- /dev/null +++ b/tests/library/library.slang @@ -0,0 +1,9 @@ +//TEST_IGNORE_FILE: + +// library.slang + +public int foo(int a) +{ + return a * a + 1; +} + -- cgit v1.2.3