summaryrefslogtreecommitdiffstats
path: root/tests/experiments/generic/explicit-specialization-2.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/experiments/generic/explicit-specialization-2.slang')
-rw-r--r--tests/experiments/generic/explicit-specialization-2.slang35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/experiments/generic/explicit-specialization-2.slang b/tests/experiments/generic/explicit-specialization-2.slang
new file mode 100644
index 000000000..ea5c74813
--- /dev/null
+++ b/tests/experiments/generic/explicit-specialization-2.slang
@@ -0,0 +1,35 @@
+//DISABLE_TEST:SIMPLE:-target hlsl -entry computeMain -profile cs_6_2
+
+/*
+The following works, but *requires* the rotateLeft free function to work around the swizzle issue (seen in explicit-specialization.slang).
+*/
+
+RWStructuredBuffer<int> outputBuffer;
+
+interface IRotatable
+{
+ This rotateLeft();
+};
+
+extension int : IRotatable
+{
+ This rotateLeft() { const uint u = this; return This((u << 1) | (u >> 31)); }
+};
+
+extension uint : IRotatable
+{
+ This rotateLeft() { let u = this; return This((u << 1) | (u >> 31)); }
+};
+
+T rotateLeft<T : IRotatable>(T a) { return a.rotateLeft(); }
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ let v = rotateLeft(tid) + rotateLeft((int)tid);
+
+ outputBuffer[tid] = v;
+}
+