summaryrefslogtreecommitdiff
path: root/tests/compute/global-type-param-array.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-21 07:09:55 -0500
committerYong He <yonghe@outlook.com>2018-01-21 07:09:55 -0500
commitce879112cb16e3def1b8673104e7123b8b17ee2a (patch)
tree9b2a63c4c2c6256d33cb32b925ed9820cf13071d /tests/compute/global-type-param-array.slang
parent913f4d09b91e3fd7449468b135881c940cacb3c0 (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/global-type-param-array.slang')
-rw-r--r--tests/compute/global-type-param-array.slang24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/compute/global-type-param-array.slang b/tests/compute/global-type-param-array.slang
new file mode 100644
index 000000000..74e52d5d4
--- /dev/null
+++ b/tests/compute/global-type-param-array.slang
@@ -0,0 +1,24 @@
+//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 Pair<Arr<Base,1>, Pair<Arr<Base,2> , Base> >
+
+RWStructuredBuffer<float> outputBuffer;
+import globalTypeParamArrayShared;
+
+__generic_param TImpl : IBase;
+
+ParameterBlock<TImpl> impl;
+
+float doCompute<T:IBase>(T t)
+{
+ return t.compute(1.0);
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ float outVal = doCompute<TImpl>(impl);
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file