From 48203ea02250ba517f749a222092f091d9bef15e Mon Sep 17 00:00:00 2001 From: Darren Wihandi <65404740+fairywreath@users.noreply.github.com> Date: Fri, 9 May 2025 23:26:43 -0400 Subject: Fix SPIRV unsigned to signed widening casts (#7051) * Fix unsigned to signed casts for SPIRV * Add test * Fix ICE crash --- tests/spirv/int-cast-unsigned-to-signed.slang | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/spirv/int-cast-unsigned-to-signed.slang (limited to 'tests/spirv') diff --git a/tests/spirv/int-cast-unsigned-to-signed.slang b/tests/spirv/int-cast-unsigned-to-signed.slang new file mode 100644 index 000000000..0ec3203a4 --- /dev/null +++ b/tests/spirv/int-cast-unsigned-to-signed.slang @@ -0,0 +1,35 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cuda -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:ubuffer(data=[200], stride=4):name input1 +RWStructuredBuffer input1; + +//TEST_INPUT:ubuffer(data=[35000], stride=4):name input2 +RWStructuredBuffer input2; + +//TEST_INPUT:ubuffer(data=[201], stride=4):name input3 +RWStructuredBuffer input3; + +// +// Tests unsigned to signed casts to wider int. +// + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint index = dispatchThreadID.x; + + // BUF: 200 + outputBuffer[index] = input1[0]; + + // BUF: 35000 + outputBuffer[index + 1] = input2[0]; + + // BUF: 201 + int16_t a = input3[0]; + outputBuffer[index + 2] = a; +} -- cgit v1.2.3