From 60a8f1fc3eee37977ee891661f65916f66aef364 Mon Sep 17 00:00:00 2001 From: Jerran Schmidt Date: Tue, 17 Jun 2025 13:49:02 +1000 Subject: 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 --- tests/spirv/swizzle-signed-typecast.slang | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/spirv/swizzle-signed-typecast.slang (limited to 'tests/spirv') 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 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 -- cgit v1.2.3