summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/dynamic-dispatch-1.slang38
-rw-r--r--tests/compute/dynamic-dispatch-1.slang.expected.txt4
-rw-r--r--tests/compute/performance-profile.slang3
3 files changed, 44 insertions, 1 deletions
diff --git a/tests/compute/dynamic-dispatch-1.slang b/tests/compute/dynamic-dispatch-1.slang
new file mode 100644
index 000000000..9e63ee124
--- /dev/null
+++ b/tests/compute/dynamic-dispatch-1.slang
@@ -0,0 +1,38 @@
+//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -allow-dynamic-code
+
+// Test dynamic dispatch code gen for non-static member functions.
+
+interface IInterface
+{
+ int Compute(int inVal);
+};
+
+int GenericCompute<T:IInterface>(T obj, int inVal)
+{
+ return obj.Compute(inVal);
+}
+
+struct Impl : IInterface
+{
+ int base;
+ int Compute(int inVal) { return base + inVal * inVal; }
+};
+
+int test(int inVal)
+{
+ Impl obj;
+ obj.base = 1;
+ return GenericCompute<Impl>(obj, inVal);
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/compute/dynamic-dispatch-1.slang.expected.txt b/tests/compute/dynamic-dispatch-1.slang.expected.txt
new file mode 100644
index 000000000..146ab3c8c
--- /dev/null
+++ b/tests/compute/dynamic-dispatch-1.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+2
+5
+A
diff --git a/tests/compute/performance-profile.slang b/tests/compute/performance-profile.slang
index bf67a4478..22f73e075 100644
--- a/tests/compute/performance-profile.slang
+++ b/tests/compute/performance-profile.slang
@@ -44,8 +44,9 @@ static void _calc(const RWStructuredBuffer<float>& buf, int start, int end)
}
SLANG_PRELUDE_EXPORT
-void computeMain(ComputeVaryingInput* varyingInput, UniformEntryPointParams* params, LocalUniformState* uniformState)
+void computeMain(ComputeVaryingInput* varyingInput, void* inParams, void* inUniformState)
{
+ LocalUniformState* uniformState = (LocalUniformState*)inUniformState;
_calc(uniformState->outputBuffer_0, varyingInput->startGroupID.x * 16, varyingInput->endGroupID.x * 16);
}