summaryrefslogtreecommitdiffstats
path: root/tests/spirv
diff options
context:
space:
mode:
authorJerran Schmidt <jerranschmidt@gmail.com>2025-06-17 13:49:02 +1000
committerGitHub <noreply@github.com>2025-06-16 20:49:02 -0700
commit60a8f1fc3eee37977ee891661f65916f66aef364 (patch)
tree7c6b93260a4b1b672876769717984b587965a17d /tests/spirv
parenta4345725a083651c16795d27fedd769f2d7e55ae (diff)
Fix for missing signedness cast in SwizzleIR (#7448)
* Cast if there is a signedness mismatch on the swizzle * Move isSignedType to slang-util and add test --------- Co-authored-by: Yong He <yonghe@outlook.com>
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