From f59df3814a514cab01f69a24e3330d13de3f9c92 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 31 Oct 2019 15:02:18 -0400 Subject: Reference IR modules with entry point (#1101) * Added RiffReadHelper * Move type to fourCC in Chunk simplifies some code. * Make MemoryArena able to track external blocks. Allow ownership of Data to vary. Changed IR serialization to use moved allocations to avoid copies. As it turns out all of the array writes could use unowned data, but doing so requires the IRData to stay in scope longer than IRSerialData, which it does at the moment - but perhaps needs better naming or a control for the feature. * Write out slang-module container. * WIP on -r option. Loading modules - with -r. * Making the serialized-module run (without using imported module). * Split compiling module from the test. * Separate module compilation with a function working. * Remove serialization test as not used. * Fix warning on gcc. * Updated test to have types across module boundary. * Allow entry point declaration. A test that tries to build with just an entry point declaration and a module. * Try to make link work with multiple modules. * Multi module linking first pass working. * Multi module test working with -module-name option * Use isDefinition - for determining to add decorations to entry point lowering. --- .../serialized-module-entry-point-test.slang | 10 +++++++++ ...ized-module-entry-point-test.slang.expected.txt | 4 ++++ .../serialized-module-entry-point.slang | 26 ++++++++++++++++++++++ tests/serialization/serialized-module-test.slang | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/serialization/serialized-module-entry-point-test.slang create mode 100644 tests/serialization/serialized-module-entry-point-test.slang.expected.txt create mode 100644 tests/serialization/serialized-module-entry-point.slang (limited to 'tests') diff --git a/tests/serialization/serialized-module-entry-point-test.slang b/tests/serialization/serialized-module-entry-point-test.slang new file mode 100644 index 000000000..51bc8a57f --- /dev/null +++ b/tests/serialization/serialized-module-entry-point-test.slang @@ -0,0 +1,10 @@ +// serialized-module-entry-point-test.slang + +//TEST:COMPILE: -module-name module -target hlsl -profile cs_5_0 -entry computeMain tests/serialization/serialized-module-entry-point.slang -o tests/serialization/serialized-module-entry-point.slang-module +//TEST:COMPILE: -module-name module tests/serialization/serialized-module.slang -o tests/serialization/serialized-module.slang-module +//TEST:COMPARE_COMPUTE_EX: -xslang -module-name -xslang module -slang -compute -xslang -r -xslang tests/serialization/serialized-module-entry-point.slang-module -xslang -r -xslang tests/serialization/serialized-module.slang-module + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID); \ No newline at end of file diff --git a/tests/serialization/serialized-module-entry-point-test.slang.expected.txt b/tests/serialization/serialized-module-entry-point-test.slang.expected.txt new file mode 100644 index 000000000..bc856dafa --- /dev/null +++ b/tests/serialization/serialized-module-entry-point-test.slang.expected.txt @@ -0,0 +1,4 @@ +0 +1 +2 +3 diff --git a/tests/serialization/serialized-module-entry-point.slang b/tests/serialization/serialized-module-entry-point.slang new file mode 100644 index 000000000..412a67ce6 --- /dev/null +++ b/tests/serialization/serialized-module-entry-point.slang @@ -0,0 +1,26 @@ +//TEST_IGNORE_FILE: + +// serialized-module-entry-point.slang + +struct Thing +{ + int a; + int b; +}; + +int foo(Thing thing); + +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + Thing thing; + + int index = (int)dispatchThreadID.x; + + thing.a = index; + thing.b = -index; + + outputBuffer[index] = foo(thing); +} diff --git a/tests/serialization/serialized-module-test.slang b/tests/serialization/serialized-module-test.slang index 63c31e039..b3f1d2149 100644 --- a/tests/serialization/serialized-module-test.slang +++ b/tests/serialization/serialized-module-test.slang @@ -3,7 +3,7 @@ // A test to try out the basics of module // serialization. -//TEST:SIMPLE_EX: tests/serialization/serialized-module.slang -o tests/serialization/serialized-module.slang-module +//TEST:COMPILE: tests/serialization/serialized-module.slang -o tests/serialization/serialized-module.slang-module //TEST:COMPARE_COMPUTE_EX:-slang -compute -xslang -r -xslang tests/serialization/serialized-module.slang-module //import serialized_module; -- cgit v1.2.3