From 72f86c8273b196d204213f02e73ba772201f903d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 30 Oct 2019 17:28:55 -0400 Subject: WIP: Simple separate IR module linkage working (#1100) * 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. --- tests/serialization/serialized-module-test.slang | 35 ++++++++++++++++++++++ .../serialized-module-test.slang.expected.txt | 4 +++ tests/serialization/serialized-module.slang | 15 ++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/serialization/serialized-module-test.slang create mode 100644 tests/serialization/serialized-module-test.slang.expected.txt create mode 100644 tests/serialization/serialized-module.slang (limited to 'tests/serialization') diff --git a/tests/serialization/serialized-module-test.slang b/tests/serialization/serialized-module-test.slang new file mode 100644 index 000000000..63c31e039 --- /dev/null +++ b/tests/serialization/serialized-module-test.slang @@ -0,0 +1,35 @@ +// serialized-module-test.slang + +// 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:COMPARE_COMPUTE_EX:-slang -compute -xslang -r -xslang tests/serialization/serialized-module.slang-module + +//import serialized_module; + +// This is fragile - needs match the definition in serialized_module +struct Thing +{ + int a; + int b; +}; + +// TODO: need to get the name mangling to line up! +int foo(Thing thing); + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer +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.expected.txt b/tests/serialization/serialized-module-test.slang.expected.txt new file mode 100644 index 000000000..bc856dafa --- /dev/null +++ b/tests/serialization/serialized-module-test.slang.expected.txt @@ -0,0 +1,4 @@ +0 +1 +2 +3 diff --git a/tests/serialization/serialized-module.slang b/tests/serialization/serialized-module.slang new file mode 100644 index 000000000..e94edf8d4 --- /dev/null +++ b/tests/serialization/serialized-module.slang @@ -0,0 +1,15 @@ +//TEST_IGNORE_FILE: + +// serialized-module.slang + +struct Thing +{ + int a; + int b; +}; + +int foo(Thing thing) +{ + return (thing.a + thing.b) - thing.b; +} + -- cgit v1.2.3