summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/spirv')
-rw-r--r--tests/spirv/swizzle-signed-typecast.slang26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/spirv/swizzle-signed-typecast.slang b/tests/spirv/swizzle-signed-typecast.slang
new file mode 100644
index 000000000..459dd3860
--- /dev/null
+++ b/tests/spirv/swizzle-signed-typecast.slang
@@ -0,0 +1,26 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK: %{{.*}} = OpBitcast %v2uint %{{.*}}
+
+RWTexture2D<uint3> tex;
+void fn(inout int2 origPos, uint offset)
+{
+ origPos.x += offset;
+ origPos.y += offset;
+}
+
+uint3 id(float3 coord)
+{
+ return uint3(coord);
+}
+
+[shader("compute")]
+[numthreads(1,1,1)]
+void main(uint3 threadId : SV_DispatchThreadID)
+{
+ uint3 index = id(threadId);
+ // Passing a uint3 swizzle as a parameter to a function expecting a int2 should result
+ // in an explicit typecast from unsigned to signed
+ fn(index.xy, 1);
+ tex[threadId.xy] = index;
+} \ No newline at end of file