summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-06-18 16:36:47 -0700
committerGitHub <noreply@github.com>2025-06-18 16:36:47 -0700
commit777ac6cae9776cd2d28bd5a9f627261ba9740153 (patch)
tree2b20d003b2e622e34924ff006a67a0f7d37204e5
parentef6c21af908ad72a04c6d7d22ad9cd189a44f2e3 (diff)
Fix coopvector neg intrinsic. (#7481)
* Fix coopvector neg intrinsic. * Add test case.
-rw-r--r--source/slang/hlsl.meta.slang2
-rw-r--r--tests/cooperative-vector/neg.slang27
2 files changed, 28 insertions, 1 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index ec7ff0e0d..d71e57400 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -25101,7 +25101,7 @@ struct CoopVec<T : __BuiltinArithmeticType, let N : int> : IArray<T>, IArithmeti
}
__intrinsic_op($(kIROp_Neg))
- This __pureNeg(This other);
+ static This __pureNeg(This other);
/// Returns a new cooperative vector where each component has its sign negated.
/// @return A new cooperative vector containing the negated values.
diff --git a/tests/cooperative-vector/neg.slang b/tests/cooperative-vector/neg.slang
new file mode 100644
index 000000000..60e316440
--- /dev/null
+++ b/tests/cooperative-vector/neg.slang
@@ -0,0 +1,27 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -render-feature cooperative-vector -output-using-type
+//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -render-feature cooperative-vector -dx12-experimental -use-dxil -output-using-type -profile cs_6_9 -Xslang... -Xdxc -Vd -X.
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type
+
+// CHECK: type: int32_t
+// CHECK-NEXT: -1
+// CHECK-NEXT: -2
+// CHECK-NEXT: -3
+// CHECK-NEXT: -4
+// CHECK-NEXT: -5
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int32_t> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[1 2 3 4 5], stride=4),name=input1
+ByteAddressBuffer input1;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ CoopVec<int, 5> vec1 = coopVecLoad<5, int32_t>(input1);
+
+ let result = -vec1;
+
+ for(int i = 0; i < result.getCount(); ++i)
+ outputBuffer[i] = result[i];
+}