summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/hlsl.meta.slang10
-rw-r--r--tests/bugs/gh-4533.slang20
2 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index d83059b00..b282dca2a 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -5575,6 +5575,8 @@ __generic<T : __BuiltinType, let N : int>
[require(cpp_cuda_glsl_hlsl_metal_spirv)]
bool all(vector<T,N> x)
{
+ if(N == 1)
+ return all(x[0]);
__target_switch
{
case hlsl:
@@ -5710,6 +5712,8 @@ __generic<T : __BuiltinType, let N : int>
[require(cpp_cuda_glsl_hlsl_metal_spirv)]
bool any(vector<T, N> x)
{
+ if(N == 1)
+ return any(x[0]);
__target_switch
{
case hlsl:
@@ -6066,6 +6070,8 @@ __generic<let N : int>
[require(cpp_cuda_glsl_hlsl_metal_spirv, shader5_sm_4_0)]
vector<int, N> asint(vector<uint, N> x)
{
+ if(N == 1)
+ return vector<int, N>(asint(x[0]));
__target_switch
{
case glsl: __intrinsic_asm "ivec$N0($0)";
@@ -6207,6 +6213,8 @@ __generic<let N : int>
[require(cpp_cuda_glsl_hlsl_metal_spirv, shader5_sm_4_0)]
vector<uint, N> asuint(vector<int, N> x)
{
+ if(N == 1)
+ return vector<uint, N>(asuint(x[0]));
__target_switch
{
case glsl: __intrinsic_asm "uvec$N0($0)";
@@ -12054,6 +12062,8 @@ __generic<T : __BuiltinSignedArithmeticType, let N : int>
[__readNone]
vector<int, N> sign(vector<T, N> x)
{
+ if(N == 1)
+ return vector<int, N>(sign(x[0]));
__target_switch
{
case hlsl: __intrinsic_asm "sign";
diff --git a/tests/bugs/gh-4533.slang b/tests/bugs/gh-4533.slang
new file mode 100644
index 000000000..3ee27996b
--- /dev/null
+++ b/tests/bugs/gh-4533.slang
@@ -0,0 +1,20 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -use-dxil
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-mtl
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cuda
+
+// CHECK: 0
+// CHECK-NEXT: 1
+// CHECK-NEXT: 1
+// CHECK-NEXT: 1
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint tid : SV_GroupIndex)
+{
+ vector<float,1> k = float1(tid);
+ outputBuffer[tid] = all(k) && any(k) && bool(asint(k)) && bool(asuint(k));
+}