diff options
| author | Yong He <yonghe@outlook.com> | 2018-01-21 07:09:55 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2018-01-21 07:09:55 -0500 |
| commit | ce879112cb16e3def1b8673104e7123b8b17ee2a (patch) | |
| tree | 9b2a63c4c2c6256d33cb32b925ed9820cf13071d /tests/compute | |
| parent | 913f4d09b91e3fd7449468b135881c940cacb3c0 (diff) | |
Improvements and bug fixes for global type parameters
1. allow spReflection_FindTypeByName to accept arbitrary type expression string
2. allow const int generic value to be used as expression value, and as array size
3. various bug fixes in witness table specialization / function cloning during specializeIRForEntryPoint to avoid creating duplicate global values, not copying the right definition of a function from the other module, not cloning witness tables that are required by specializeGenerics etc.
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/array-param.slang.expected.txt | 12 | ||||
| -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-param3.slang.expected.txt | 1 | ||||
| -rw-r--r-- | tests/compute/globalTypeParamArrayShared.slang | 31 |
5 files changed, 41 insertions, 27 deletions
diff --git a/tests/compute/array-param.slang.expected.txt b/tests/compute/array-param.slang.expected.txt index 61b9a3dcd..ef529012e 100644 --- a/tests/compute/array-param.slang.expected.txt +++ b/tests/compute/array-param.slang.expected.txt @@ -1,8 +1,4 @@ -0 -3F80000 -0 -3F80000 -0 -3F80000 -0 -3F80000
\ No newline at end of file +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-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..65d09f14e --- /dev/null +++ b/tests/compute/globalTypeParamArrayShared.slang @@ -0,0 +1,31 @@ +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; + } +}; |
