From d0f342c9263a0e47947ac3be9fa4d9f665831e63 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Jul 2025 03:22:59 +0000 Subject: Fix int16_t/uint16_t support for WGSL target (#7692) * Initial plan * Implement int16_t/uint16_t support for WGSL target Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Change int16_t/uint16_t to emit proper diagnostics instead of auto-promoting Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Implement diagnoseOnce to prevent duplicate diagnostics Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Optimize diagnoseOnce to use HashSet::add() return value Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply code formatting to slang-emit-c-like.h Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix diagnoseOnce to use all parameters instead of first parameter only Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> --- tests/wgsl/int16-uint16-error.slang | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/wgsl/int16-uint16-error.slang (limited to 'tests') diff --git a/tests/wgsl/int16-uint16-error.slang b/tests/wgsl/int16-uint16-error.slang new file mode 100644 index 000000000..651fe8a63 --- /dev/null +++ b/tests/wgsl/int16-uint16-error.slang @@ -0,0 +1,31 @@ +//TEST:SIMPLE(filecheck=CHECK): -target wgsl -stage compute -entry computeMain + +// Test that int16_t and uint16_t types emit diagnostics only once per type to prevent duplicates + +//CHECK: error 56103 +//CHECK: 16-bit integer type 'uint16_t' is not supported by the WGSL backend + +//CHECK: error 56103 +//CHECK: 16-bit integer type 'int16_t' is not supported by the WGSL backend + +RWStructuredBuffer buffer; + +[numthreads(1,1,1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // Test uint16_t - should produce error (first occurrence) + uint16_t test_u16 = uint16_t(dispatchThreadID.x); + buffer[0] = test_u16; + + // Test int16_t - should produce error (first occurrence of int16_t) + int16_t test_i16 = int16_t(dispatchThreadID.y); + buffer[1] = test_i16; + + // Use uint16_t again - should not produce duplicate error + uint16_t another_u16 = uint16_t(42); + buffer[2] = another_u16; + + // Use int16_t again - should not produce duplicate error + int16_t another_i16 = int16_t(123); + buffer[3] = another_i16; +} \ No newline at end of file -- cgit v1.2.3