summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCopilot <198982749+Copilot@users.noreply.github.com>2025-07-16 00:43:00 +0000
committerGitHub <noreply@github.com>2025-07-16 00:43:00 +0000
commita8519e68b6df636932ca5d89a332b2a689259b0f (patch)
tree69bb738a2b85cc3fdfba1e47994fc5362ee67859 /tests
parent652a8ee6883f08ce7cb55ef372277a535ce4d88f (diff)
Fix WGSL sign function to return correct int type instead of float (#7739)
* Initial plan * Fix WGSL sign function to return int type properly Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Add vector version check for WGSL sign function test Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix FileCheck order in WGSL sign test - use DAG for order-independent checking 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>
Diffstat (limited to 'tests')
-rw-r--r--tests/cross-compile/sign-wgsl.slang31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/cross-compile/sign-wgsl.slang b/tests/cross-compile/sign-wgsl.slang
new file mode 100644
index 000000000..60e0fceee
--- /dev/null
+++ b/tests/cross-compile/sign-wgsl.slang
@@ -0,0 +1,31 @@
+// sign-wgsl.slang
+
+//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry main -stage compute
+
+// Test that sign function returns correct type for WGSL
+// WGSL's sign returns float but Slang's sign should return int
+
+struct OutputBuffer
+{
+ int scalar_result;
+ int2 vector_result;
+};
+
+[[vk::binding(0, 0)]]
+RWStructuredBuffer<OutputBuffer> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void main()
+{
+ // Test scalar sign function
+ int scalar_result = sign(0.5);
+
+ // Test vector sign function
+ int2 vector_result = sign(float2(1.5, -0.5));
+
+ outputBuffer[0].scalar_result = scalar_result;
+ outputBuffer[0].vector_result = vector_result;
+
+ // WGSL-DAG: i32(sign(
+ // WGSL-DAG: vec2<i32>(sign((vec2<f32>
+} \ No newline at end of file