diff options
| author | YONGH\yongh <yonghe@outlook.com> | 2017-10-30 21:18:20 -0400 |
|---|---|---|
| committer | YONGH\yongh <yonghe@outlook.com> | 2017-10-30 21:18:20 -0400 |
| commit | 84f381cc180b3176d6a58da4085ee8470f246922 (patch) | |
| tree | 4c20475c42b33a1e719237c573106eaeb5698322 /tests | |
| parent | 91ac1555d7838961c3b5c41d5af39c7a881f59eb (diff) | |
work in-progress, add parsing for assoc type decls and member type expressions
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/assoctype-simple.slang | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/compute/assoctype-simple.slang b/tests/compute/assoctype-simple.slang new file mode 100644 index 000000000..5a2c339a6 --- /dev/null +++ b/tests/compute/assoctype-simple.slang @@ -0,0 +1,34 @@ +//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +// Confirm that generics syntax can be used in user +// code and generates valid output. + +RWStructuredBuffer<float> outputBuffer; + +interface ISimple +{ + assoctype T; + T add(T v0, T v1); +} + +struct Simple : ISimple +{ + typedef float T; + T add(T v0, float v1) + { + return v0 + v1; + } +}; + +__generic<T:ISimple> +T.T test(T simple, T.T v0, T.T v1) +{ + return simple.add(v0, v1); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float outVal = test<Simple>(Simple(), 2.0, 1.0); // == 3.0 + outputBuffer[tid] = outVal; +}
\ No newline at end of file |
