diff options
Diffstat (limited to 'tests/serialization')
| -rw-r--r-- | tests/serialization/extern/extern-test.slang | 26 | ||||
| -rw-r--r-- | tests/serialization/extern/extern-test.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/serialization/extern/module-a.slang | 23 | ||||
| -rw-r--r-- | tests/serialization/extern/module-b.slang | 14 |
4 files changed, 67 insertions, 0 deletions
diff --git a/tests/serialization/extern/extern-test.slang b/tests/serialization/extern/extern-test.slang new file mode 100644 index 000000000..0079a3527 --- /dev/null +++ b/tests/serialization/extern/extern-test.slang @@ -0,0 +1,26 @@ +// serialized-module-entry-point-test.slang + +//TEST:COMPILE: -module-name module -no-codegen tests/serialization/extern/module-a.slang -o tests/serialization/extern/module-a.slang-lib +//TEST:COMPILE: -module-name module -no-codegen tests/serialization/extern/module-b.slang -o tests/serialization/extern/module-b.slang-lib +//TEST:COMPARE_COMPUTE_EX: -xslang -module-name -xslang module -slang -compute -xslang -r -xslang tests/serialization/extern/module-a.slang-lib -xslang -r -xslang tests/serialization/extern/module-b.slang-lib + +//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +// Declare the type exists +[__extern] struct Thing {}; +// A mechanism to make a Thing without knowing the specific fields. +[__extern] Thing makeThing(int a, int b); + +[__extern] int doSomething(Thing a, Thing b); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = int(dispatchThreadID.x); + + Thing a = makeThing(index + 1, index + 2); + Thing b = makeThing(-index , index * 2); + + outputBuffer[index] = doSomething(a, b); +}
\ No newline at end of file diff --git a/tests/serialization/extern/extern-test.slang.expected.txt b/tests/serialization/extern/extern-test.slang.expected.txt new file mode 100644 index 000000000..e326b6740 --- /dev/null +++ b/tests/serialization/extern/extern-test.slang.expected.txt @@ -0,0 +1,4 @@ +5 +B +11 +17 diff --git a/tests/serialization/extern/module-a.slang b/tests/serialization/extern/module-a.slang new file mode 100644 index 000000000..81816a213 --- /dev/null +++ b/tests/serialization/extern/module-a.slang @@ -0,0 +1,23 @@ +//TEST_IGNORE_FILE: + +// module-a.slang + +struct Thing +{ + int a; + int b; +}; + +Thing makeThing(int a, int b) +{ + Thing thing; + thing.a = a; + thing.b = b; + return thing; +} + +int foo(Thing thing) +{ + return thing.a + thing.b * 2; +} + diff --git a/tests/serialization/extern/module-b.slang b/tests/serialization/extern/module-b.slang new file mode 100644 index 000000000..20371f156 --- /dev/null +++ b/tests/serialization/extern/module-b.slang @@ -0,0 +1,14 @@ +//TEST_IGNORE_FILE: + +// module-b.slang + +// This looks like a definition (and it is) but with [__extern] it's definition will be replaced at link time with a defintion +[__extern] struct Thing {}; +[__extern] int foo(Thing thing); + +int doSomething(Thing a, Thing b) +{ + return foo(a) + foo(b); +} + + |
