summaryrefslogtreecommitdiffstats
path: root/tests/compute/interface-static-method.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compute/interface-static-method.slang')
-rw-r--r--tests/compute/interface-static-method.slang56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/compute/interface-static-method.slang b/tests/compute/interface-static-method.slang
new file mode 100644
index 000000000..4747c8a8a
--- /dev/null
+++ b/tests/compute/interface-static-method.slang
@@ -0,0 +1,56 @@
+// interface-static-method.slang
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+
+interface IHideout
+{
+ int getAnimalCount();
+}
+
+interface ISuperhero
+{
+ associatedtype Hideout : IHideout;
+
+ static Hideout getHideout();
+}
+
+struct Batcave : IHideout
+{
+ int batCount;
+
+ int getAnimalCount() { return batCount; }
+}
+
+struct Batman : ISuperhero
+{
+ typedef Batcave Hideout;
+
+ static Batcave getHideout()
+ {
+ Batcave batcave = { 100 };
+ return batcave;
+ }
+}
+
+int doIt<T:ISuperhero>()
+{
+ return T.getHideout().getAnimalCount();
+}
+
+int test(int val)
+{
+ return doIt<Batman>();
+}
+
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int tid = dispatchThreadID.x;
+ outputBuffer[tid] = test(tid);
+} \ No newline at end of file