diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-21 10:48:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-21 10:48:31 -0800 |
| commit | 4044a1d3a0605198465a7eb6e0e3c1f8b1a3c298 (patch) | |
| tree | 62927d4d2722b36c8e7eb4060e741b9032686835 /tests | |
| parent | 2079b941bc5849b6ab33774fb90cefe9c2d624cb (diff) | |
| parent | f681a1505c98995683a7fbae7ce208dc5e444b9b (diff) | |
Merge pull request #372 from csyonghe/master
Allow type expression as type argument, fix global param enum order
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/array-param.slang | 19 | ||||
| -rw-r--r-- | tests/compute/array-param.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/global-type-param-array.slang (renamed from tests/compute/global-type-param3.slang) | 23 | ||||
| -rw-r--r-- | tests/compute/global-type-param-array.slang.expected.txt | 1 | ||||
| -rw-r--r-- | tests/compute/global-type-param.slang | 11 | ||||
| -rw-r--r-- | tests/compute/global-type-param3.slang.expected.txt | 1 | ||||
| -rw-r--r-- | tests/compute/globalTypeParamArrayShared.slang | 32 |
7 files changed, 71 insertions, 20 deletions
diff --git a/tests/compute/array-param.slang b/tests/compute/array-param.slang new file mode 100644 index 000000000..78ca52518 --- /dev/null +++ b/tests/compute/array-param.slang @@ -0,0 +1,19 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +RWStructuredBuffer<int> outputBuffer; +void writeArray(inout float3 a[4]) +{ + a[0] = float3(1, 1, 1); + a[1] = float3(1, 1, 1); + a[2] = float3(1, 1, 1); + a[3] = float3(1, 1, 1); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float3 b[4]; + writeArray(b); + outputBuffer[dispatchThreadID.x] = b[0].x; +}
\ No newline at end of file diff --git a/tests/compute/array-param.slang.expected.txt b/tests/compute/array-param.slang.expected.txt new file mode 100644 index 000000000..ef529012e --- /dev/null +++ b/tests/compute/array-param.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +1 +1
\ No newline at end of file diff --git a/tests/compute/global-type-param3.slang b/tests/compute/global-type-param-array.slang index 05793dce4..74e52d5d4 100644 --- a/tests/compute/global-type-param3.slang +++ b/tests/compute/global-type-param-array.slang @@ -1,23 +1,10 @@ -//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir -//TEST_INPUT: cbuffer(data=[1.0], stride=4):dxbinding(0),glbinding(0) +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT: cbuffer(data=[1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0], stride=4):dxbinding(0),glbinding(0) //TEST_INPUT: ubuffer(data=[0], stride=4):dxbinding(0),glbinding(0),out -//TEST_INPUT: type Impl +//TEST_INPUT: type Pair<Arr<Base,1>, Pair<Arr<Base,2> , Base> > RWStructuredBuffer<float> outputBuffer; - -interface IBase -{ - float compute(); -} - -struct Impl : IBase -{ - float base; // = 1.0 - float compute() - { - return 1.0; - } -}; +import globalTypeParamArrayShared; __generic_param TImpl : IBase; @@ -25,7 +12,7 @@ ParameterBlock<TImpl> impl; float doCompute<T:IBase>(T t) { - return t.compute(); + return t.compute(1.0); } [numthreads(1, 1, 1)] diff --git a/tests/compute/global-type-param-array.slang.expected.txt b/tests/compute/global-type-param-array.slang.expected.txt new file mode 100644 index 000000000..bdf6b77dc --- /dev/null +++ b/tests/compute/global-type-param-array.slang.expected.txt @@ -0,0 +1 @@ +40800000 diff --git a/tests/compute/global-type-param.slang b/tests/compute/global-type-param.slang index 301ef1021..03f5df329 100644 --- a/tests/compute/global-type-param.slang +++ b/tests/compute/global-type-param.slang @@ -1,6 +1,6 @@ //TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir //TEST_INPUT:ubuffer(data=[0], stride=4):dxbinding(0),glbinding(0),out -//TEST_INPUT:type Impl +//TEST_INPUT:type Wrapper<Impl> RWStructuredBuffer<float> outputBuffer; @@ -9,6 +9,15 @@ interface IBase float compute(); } +struct Wrapper<T : IBase> : IBase +{ + T obj; + float compute() + { + return obj.compute(); + } +}; + struct Impl : IBase { float compute() diff --git a/tests/compute/global-type-param3.slang.expected.txt b/tests/compute/global-type-param3.slang.expected.txt deleted file mode 100644 index deb1c3630..000000000 --- a/tests/compute/global-type-param3.slang.expected.txt +++ /dev/null @@ -1 +0,0 @@ -3F800000 diff --git a/tests/compute/globalTypeParamArrayShared.slang b/tests/compute/globalTypeParamArrayShared.slang new file mode 100644 index 000000000..ee3caa372 --- /dev/null +++ b/tests/compute/globalTypeParamArrayShared.slang @@ -0,0 +1,32 @@ +//TEST_IGNORE_FILE: +interface IBase +{ + float compute<T>(T g); +} +struct Base:IBase +{ + float b; + float compute<T>(T g) { return b; } +}; + +struct Pair<T1:IBase, T2:IBase> : IBase +{ + T1 head; + T2 tail; + float compute<T>(T g) + { + return head.compute(g) + tail.compute(g); + } +}; + +struct Arr<T:IBase, let N:int> : IBase +{ + T base[N]; // = 1.0 + float compute<T>(T g) + { + float sum = 0.0; + for (int i = 0; i < N; i++) + sum += base[i].compute(g); + return sum; + } +}; |
