diff options
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/generic-struct.slang | 37 | ||||
| -rw-r--r-- | tests/compute/generic-struct.slang.expected.txt | 4 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/compute/generic-struct.slang b/tests/compute/generic-struct.slang new file mode 100644 index 000000000..fd56ae0e9 --- /dev/null +++ b/tests/compute/generic-struct.slang @@ -0,0 +1,37 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +// Check that user code can declare and use a generic +// `struct` type. + +RWStructuredBuffer<int> outputBuffer; + +__generic<T> +struct GenStruct +{ + T x; + T y; +}; + +__generic<T> +T test(T val) +{ + GenStruct<T> gs; + gs.x = val; + gs.y = val; + return gs.x; +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + float outVal = 0; + + outVal += test<uint>(tid); + outVal += test<float>(tid * 16.0f); + + outputBuffer[tid] = int(outVal); +}
\ No newline at end of file diff --git a/tests/compute/generic-struct.slang.expected.txt b/tests/compute/generic-struct.slang.expected.txt new file mode 100644 index 000000000..d4cb1cc00 --- /dev/null +++ b/tests/compute/generic-struct.slang.expected.txt @@ -0,0 +1,4 @@ +0 +11 +22 +33 |
