summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Helferty (NVIDIA) <jhelferty@nvidia.com>2025-09-30 14:21:27 -0400
committerGitHub <noreply@github.com>2025-09-30 18:21:27 +0000
commit8086adc90b69f3199767c0617e2c429ce6b27f67 (patch)
treecbc54d5dbb3ad13329abc49f3aabf25ee199b7d6
parentee5adb87050ae7c0b96056a67dddc5d48174e695 (diff)
Enable metal tests (#8446)
Enables all tests/metal/ tests that can be easily enabled. These tests were not originally designed as render tests; they are generally being enabled for pipecleaning purposes, and will not be rigorously testing the corresponding funcitonality. Where they cannot be enabled as render tests, and a metallib test wasn't already enabled, a metallib test was enabled instead (where possible). Fixes #7892
-rw-r--r--tests/hlsl-intrinsic/atomic/atomic-intrinsics-64bit.slang13
-rw-r--r--tests/hlsl-intrinsic/atomic/atomic-intrinsics.slang28
-rw-r--r--tests/metal/8bit-vector-types.slang12
-rw-r--r--tests/metal/atomic-byteaddressbuffer.slang29
-rw-r--r--tests/metal/atomic-intrinsics.slang14
-rw-r--r--tests/metal/atomic-texture-buffer.slang4
-rw-r--r--tests/metal/atomic-texture-texture1d.slang183
-rw-r--r--tests/metal/atomic-texture-texture1d.slang.2.expected.txt93
-rw-r--r--tests/metal/atomic-texture-texture1d.slang.3.expected.txt93
-rw-r--r--tests/metal/atomic-texture-texture2d.slang183
-rw-r--r--tests/metal/atomic-texture-texture2d.slang.2.expected.txt93
-rw-r--r--tests/metal/atomic-texture-texture2d.slang.3.expected.txt93
-rw-r--r--tests/metal/atomic-texture-texture3d.slang102
-rw-r--r--tests/metal/atomic-texture-texture3d.slang.2.expected.txt47
-rw-r--r--tests/metal/atomic-texture-texture3d.slang.3.expected.txt47
-rw-r--r--tests/metal/barrier.slang16
-rw-r--r--tests/metal/barycentrics.slang8
-rw-r--r--tests/metal/byte-address-buffer.slang43
-rw-r--r--tests/metal/byte-address-buffer.slang.2.expected.txt75
-rw-r--r--tests/metal/byte-address-buffer.slang.3.expected.txt75
-rw-r--r--tests/metal/depth-texture.slang13
-rw-r--r--tests/metal/discard.slang10
-rw-r--r--tests/metal/empty-struct-remove.slang5
-rw-r--r--tests/metal/explicit-location.slang7
-rw-r--r--tests/metal/groupshared.slang20
-rw-r--r--tests/metal/math.slang43
-rw-r--r--tests/metal/matrix-bool-lowering.slang39
-rw-r--r--tests/metal/matrix-integer-lowering.slang86
-rw-r--r--tests/metal/matrix-negate.slang12
-rw-r--r--tests/metal/metal-pointer-params.slang24
-rw-r--r--tests/metal/metal-pointer-uniform.slang24
-rw-r--r--tests/metal/multi-entry-point-params.slang13
-rw-r--r--tests/metal/nested-parameter-block-reflection.slang27
-rw-r--r--tests/metal/out-param.slang21
-rw-r--r--tests/metal/pointer-literals.slang6
-rw-r--r--tests/metal/simple-compute.slang20
-rw-r--r--tests/metal/simple-mesh.slang5
-rw-r--r--tests/metal/simple-task.slang4
-rw-r--r--tests/metal/stage-in-2.slang6
-rw-r--r--tests/metal/stage-in.slang68
-rw-r--r--tests/metal/sv_target-complex-1.slang4
-rw-r--r--tests/metal/sv_target-complex-2.slang4
-rw-r--r--tests/metal/sv_target.slang14
-rw-r--r--tests/metal/system-val-conversion.slang25
-rw-r--r--tests/metal/test_buffer.slang4
-rw-r--r--tests/metal/test_descriptor_handle.slang6
-rw-r--r--tests/metal/texture-multisample.slang11
-rw-r--r--tests/metal/texture-store-vector.slang10
-rw-r--r--tests/metal/texture-write.slang63
-rw-r--r--tests/metal/texture.slang4
-rw-r--r--tests/metal/thread_position_in_threadgroup.slang22
-rw-r--r--tests/metal/vector-argument-buffer-layout.slang23
-rw-r--r--tests/metal/vector-get-element-ptr.slang9
-rw-r--r--tests/pipeline/rasterization/mesh/dead-loop.slang1
54 files changed, 1411 insertions, 493 deletions
diff --git a/tests/hlsl-intrinsic/atomic/atomic-intrinsics-64bit.slang b/tests/hlsl-intrinsic/atomic/atomic-intrinsics-64bit.slang
index da5af8a5c..53b402d22 100644
--- a/tests/hlsl-intrinsic/atomic/atomic-intrinsics-64bit.slang
+++ b/tests/hlsl-intrinsic/atomic/atomic-intrinsics-64bit.slang
@@ -1,5 +1,5 @@
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_6 -shaderobj -output-using-type
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -cuda -profile cs_6_6 -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -profile cs_6_6 -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -cuda -profile cs_6_6 -shaderobj -output-using-type
// This is to support 64-bit `Interlocked*` functions defined for HLSL SM6.6
// https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Int64_and_Float_Atomics.html
@@ -334,10 +334,9 @@ void computeMain(uint groupIndex : SV_GroupIndex, int3 dispatchThreadID: SV_Disp
&& (fBuf.Load<float>(idx * 8) == float(1))
;
+ // BUF: 1
+ // BUF-NEXT: 1
+ // BUF-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[idx] = int(result);
}
-
-// CHK: 1
-// CHK-NEXT: 1
-// CHK-NEXT: 1
-// CHK-NEXT: 1
diff --git a/tests/hlsl-intrinsic/atomic/atomic-intrinsics.slang b/tests/hlsl-intrinsic/atomic/atomic-intrinsics.slang
index 370db784d..b6e1a6ead 100644
--- a/tests/hlsl-intrinsic/atomic/atomic-intrinsics.slang
+++ b/tests/hlsl-intrinsic/atomic/atomic-intrinsics.slang
@@ -1,9 +1,10 @@
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=DX12):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type -xslang -DDX12
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=VK):-vk -emit-spirv-directly -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=VK):-vk -emit-spirv-via-glsl -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK -xslang -minimum-slang-optimization
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=VK):-vk -emit-spirv-via-glsl -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CUDA):-cuda -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type -xslang -DDX12
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -emit-spirv-directly -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -emit-spirv-via-glsl -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK -xslang -minimum-slang-optimization
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -emit-spirv-via-glsl -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DVK
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cuda -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -shaderobj -output-using-type
//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):name=uintBuffer
@@ -269,18 +270,9 @@ void computeMain(uint groupIndex : SV_GroupIndex, int3 dispatchThreadID: SV_Disp
val += intBuffer[idx];
val += origi;
+ // BUF: 184
+ // BUF-NEXT: 207
+ // BUF-NEXT: 230
+ // BUF-NEXT: 253
outputBuffer[idx] = val;
}
-
-// DX12: 184
-// DX12: 207
-// DX12: 230
-// DX12: 253
-// VK: 184
-// VK: 207
-// VK: 230
-// VK: 253
-// CUDA: 184
-// CUDA: 207
-// CUDA: 230
-// CUDA: 253 \ No newline at end of file
diff --git a/tests/metal/8bit-vector-types.slang b/tests/metal/8bit-vector-types.slang
index 8bfb65fc8..a78bd6273 100644
--- a/tests/metal/8bit-vector-types.slang
+++ b/tests/metal/8bit-vector-types.slang
@@ -1,5 +1,8 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=MTL): -target metal -stage compute -entry computeMain
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
+//TEST_INPUT:ubuffer(data=[0], stride=4, counter=1):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
uint8_t2 createUChar2()
@@ -15,10 +18,11 @@ int8_t2 createChar2()
[numthreads(1, 1, 1)]
void computeMain()
{
- // CHECK: uchar2
- // CHECK: char2
+ // MTL: uchar2
+ // MTL: char2
uint8_t2 u8v2 = createUChar2();
int8_t2 i8v2 = createChar2();
+ // BUF: {{^}}4{{$}}
outputBuffer[0] = u8v2.x + i8v2.x;
-} \ No newline at end of file
+}
diff --git a/tests/metal/atomic-byteaddressbuffer.slang b/tests/metal/atomic-byteaddressbuffer.slang
index 96c338d28..1bedf4bc6 100644
--- a/tests/metal/atomic-byteaddressbuffer.slang
+++ b/tests/metal/atomic-byteaddressbuffer.slang
@@ -1,7 +1,8 @@
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cuda -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cuda -compute -shaderobj -output-using-type
//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute -DMETAL
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -shaderobj -output-using-type
//TEST_INPUT:ubuffer(data=[0 0 0 0 0]):name=uintBuffer
RWByteAddressBuffer uintBuffer;
@@ -16,42 +17,42 @@ void computeMain()
int oldValue;
//LIB: call {{.*}}.atomic.global.add.u.i32
uintBuffer.InterlockedAdd(0, 1, oldValue);
- // CHK: 1
+ // BUF: 1
outputBuffer[0] = oldValue;
uintBuffer.InterlockedAdd(0, 1, oldValue);
- // CHK: 2
+ // BUF: 2
outputBuffer[1] = (int)oldValue;
uintBuffer.InterlockedCompareExchange(0, 3, 4, oldValue);
- // CHK: 3
+ // BUF: 3
outputBuffer[2] = (int)oldValue;
uintBuffer.InterlockedOr(0, 3, oldValue);
- // CHK: 4
+ // BUF: 4
outputBuffer[3] = oldValue; // 4
uintBuffer.InterlockedExchange(0, 4, oldValue);
- // CHK: 7
+ // BUF: 7
outputBuffer[4] = oldValue; // 7
uintBuffer.InterlockedMin(0, 3, oldValue);
- // CHK: 4
+ // BUF: 4
outputBuffer[5] = oldValue; // 4
uintBuffer.InterlockedMax(0, 4, oldValue);
- // CHK: 3
+ // BUF: 3
outputBuffer[6] = oldValue; // 3
uintBuffer.InterlockedAnd(0, 7, oldValue);
- // CHK: 4
+ // BUF: 4
outputBuffer[7] = oldValue; // 4
uintBuffer.InterlockedXor(0, 7, oldValue);
- // CHK: 4
+ // BUF: 4
outputBuffer[8] = oldValue; // 4
- // CHK: 3
+ // BUF: 3
outputBuffer[9] = uintBuffer.Load(0);
-} \ No newline at end of file
+}
diff --git a/tests/metal/atomic-intrinsics.slang b/tests/metal/atomic-intrinsics.slang
index 26f7eac41..ebb82948e 100644
--- a/tests/metal/atomic-intrinsics.slang
+++ b/tests/metal/atomic-intrinsics.slang
@@ -1,7 +1,8 @@
//TEST:SIMPLE(filecheck=MTL):-target metal -entry computeMain -stage compute -DMETAL
//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute -DMETAL
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -profile cs_6_0 -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -output-using-type
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
@@ -343,10 +344,9 @@ void computeMain(uint groupIndex : SV_GroupIndex)
val += intBuffer[idx];
val += origi;
+ // BUF: 184
+ // BUF-NEXT: 207
+ // BUF-NEXT: 230
+ // BUF-NEXT: 253
outputBuffer[idx] = val;
}
-
-// CHK: 184
-// CHK: 207
-// CHK: 230
-// CHK: 253
diff --git a/tests/metal/atomic-texture-buffer.slang b/tests/metal/atomic-texture-buffer.slang
index a8f909255..1c39b7596 100644
--- a/tests/metal/atomic-texture-buffer.slang
+++ b/tests/metal/atomic-texture-buffer.slang
@@ -2,6 +2,10 @@
//TEST:SIMPLE(filecheck=METAL_FLOAT): -target metal -stage compute -entry computeMain -DFLOAT
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+// Test framework does not support RWBuffer
+// TODO: github issue #8456
+
+
// METAL_FLOAT: floating point atomic operation
//METALLIB: @computeMain
diff --git a/tests/metal/atomic-texture-texture1d.slang b/tests/metal/atomic-texture-texture1d.slang
index 746021fd6..1976eb8a0 100644
--- a/tests/metal/atomic-texture-texture1d.slang
+++ b/tests/metal/atomic-texture-texture1d.slang
@@ -1,22 +1,31 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+//TEST(compute, metal):COMPARE_COMPUTE_EX:-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
//METALLIB: @computeMain
+//TEST_INPUT: RWTexture1D(format=R32Uint, size=15, content=one):name uintTexture1D
RWTexture1D<uint> uintTexture1D;
+//TEST_INPUT: RWTexture1D(format=R32Sint, size=15, content=one):name intTexture1D
RWTexture1D<int> intTexture1D;
+//TEST_INPUT: RWTexture1D(format=R32Uint, size=15, content=one, arrayLength=2):name uintTexture1DArray
RWTexture1DArray<uint> uintTexture1DArray;
+//TEST_INPUT: RWTexture1D(format=R32Sint, size=15, content=one, arrayLength=2):name intTexture1DArray
RWTexture1DArray<int> intTexture1DArray;
+//TEST_INPUT: ubuffer(data=[0], stride=1, count=368):out,name outBuffer
+RWStructuredBuffer<int> outBuffer;
+
void test()
{
- int valInt = 1;
- int originalValueInt;
+ int valInt = 3;
+ int originalValueInt = 999;
int compareValueInt = 1;
- uint valUInt = 1;
- uint originalValueUInt;
+ uint valUInt = 3;
+ uint originalValueUInt = 999;
int compareValueUInt = 1;
// Texture1D
@@ -51,37 +60,56 @@ void test()
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
- InterlockedAdd(intTexture1D[0], valInt);
- InterlockedAnd(intTexture1D[0], valInt);
- InterlockedMax(intTexture1D[0], valInt);
- InterlockedMin(intTexture1D[0], valInt);
- InterlockedOr(intTexture1D[0], valInt);
- InterlockedXor(intTexture1D[0], valInt);
- InterlockedAdd(intTexture1D[0], valInt, originalValueInt);
- InterlockedAnd(intTexture1D[0], valInt, originalValueInt);
- InterlockedMax(intTexture1D[0], valInt, originalValueInt);
- InterlockedMin(intTexture1D[0], valInt, originalValueInt);
- InterlockedOr(intTexture1D[0], valInt, originalValueInt);
- InterlockedXor(intTexture1D[0], valInt, originalValueInt);
- InterlockedExchange(intTexture1D[0], valInt, originalValueInt);
- InterlockedCompareExchange(intTexture1D[0], valInt, compareValueInt, originalValueInt);
- InterlockedCompareStore(intTexture1D[0], valInt, compareValueUInt);
+ int o = 0;
+ int i = 0;
+ InterlockedAdd(uintTexture1D[i++], valUInt);
+ InterlockedAnd(uintTexture1D[i++], valUInt);
+ InterlockedMax(uintTexture1D[i++], valUInt);
+ InterlockedMin(uintTexture1D[i++], valUInt);
+ InterlockedOr(uintTexture1D[i++], valUInt);
+ InterlockedXor(uintTexture1D[i++], valUInt);
+ InterlockedAdd(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedAnd(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMax(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMin(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedOr(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedXor(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedExchange(uintTexture1D[i++], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareExchange(uintTexture1D[i++], valUInt, compareValueUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareStore(uintTexture1D[i++], valUInt, compareValueUInt);
- InterlockedAdd(uintTexture1D[0], valUInt);
- InterlockedAnd(uintTexture1D[0], valUInt);
- InterlockedMax(uintTexture1D[0], valUInt);
- InterlockedMin(uintTexture1D[0], valUInt);
- InterlockedOr(uintTexture1D[0], valUInt);
- InterlockedXor(uintTexture1D[0], valUInt);
- InterlockedAdd(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedAnd(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedMax(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedMin(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedOr(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedXor(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedExchange(uintTexture1D[0], valUInt, originalValueUInt);
- InterlockedCompareExchange(uintTexture1D[0], valUInt, compareValueUInt, originalValueUInt);
- InterlockedCompareStore(uintTexture1D[0], valUInt, compareValueUInt);
+ i = 0;
+ InterlockedAdd(intTexture1D[i++], valInt);
+ InterlockedAnd(intTexture1D[i++], valInt);
+ InterlockedMax(intTexture1D[i++], valInt);
+ InterlockedMin(intTexture1D[i++], valInt);
+ InterlockedOr(intTexture1D[i++], valInt);
+ InterlockedXor(intTexture1D[i++], valInt);
+ InterlockedAdd(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedAnd(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMax(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMin(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedOr(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedXor(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedExchange(intTexture1D[i++], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareExchange(intTexture1D[i++], valInt, compareValueInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareStore(intTexture1D[i++], valInt, compareValueUInt);
// Texture1DArray
// METAL: .atomic_fetch_add
@@ -115,37 +143,64 @@ void test()
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
- InterlockedAdd(intTexture1DArray[0], valInt);
- InterlockedAnd(intTexture1DArray[0], valInt);
- InterlockedMax(intTexture1DArray[0], valInt);
- InterlockedMin(intTexture1DArray[0], valInt);
- InterlockedOr(intTexture1DArray[0], valInt);
- InterlockedXor(intTexture1DArray[0], valInt);
- InterlockedAdd(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedAnd(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedMax(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedMin(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedOr(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedXor(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedExchange(intTexture1DArray[0], valInt, originalValueInt);
- InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueInt);
- InterlockedCompareStore(intTexture1DArray[0], valUInt, compareValueUInt);
+ i = 0;
+ InterlockedAdd(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedAnd(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedMax(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedMin(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedOr(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedXor(uintTexture1DArray[uint2(i++, 0)], valUInt);
+ InterlockedAdd(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedAnd(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMax(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMin(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedOr(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedXor(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedExchange(uintTexture1DArray[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareExchange(uintTexture1DArray[uint2(i++, 0)], valUInt, compareValueUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareStore(uintTexture1DArray[uint2(i++, 0)], valUInt, compareValueUInt);
+
+ i = 0;
+ InterlockedAdd(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedAnd(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedMax(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedMin(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedOr(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedXor(intTexture1DArray[uint2(i++, 0)], valInt);
+ InterlockedAdd(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedAnd(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMax(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMin(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedOr(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedXor(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedExchange(intTexture1DArray[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareExchange(intTexture1DArray[uint2(i++, 0)], valInt, compareValueInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareStore(intTexture1DArray[uint2(i++, 0)], valUInt, compareValueUInt);
- InterlockedAdd(uintTexture1DArray[0], valUInt);
- InterlockedAnd(uintTexture1DArray[0], valUInt);
- InterlockedMax(uintTexture1DArray[0], valUInt);
- InterlockedMin(uintTexture1DArray[0], valUInt);
- InterlockedOr(uintTexture1DArray[0], valUInt);
- InterlockedXor(uintTexture1DArray[0], valUInt);
- InterlockedAdd(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedAnd(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedMax(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedMin(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedOr(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedXor(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedExchange(uintTexture1DArray[0], valUInt, originalValueUInt);
- InterlockedCompareExchange(uintTexture1DArray[0], valUInt, compareValueUInt, originalValueUInt);
- InterlockedCompareStore(uintTexture1DArray[0], valUInt, compareValueUInt);
+ // Copy to output
+ int test_count = i;
+ for (i=0; i<test_count; i++) {
+ outBuffer[o + test_count*0 + i] = uintTexture1D[i];
+ outBuffer[o + test_count*1 + i] = intTexture1D[i];
+ outBuffer[o + test_count*2 + i] = uintTexture1DArray[uint2(i, 0)];
+ outBuffer[o + test_count*3 + i] = intTexture1DArray[uint2(i, 0)];
+ }
}
[numthreads(1, 1, 1)]
diff --git a/tests/metal/atomic-texture-texture1d.slang.2.expected.txt b/tests/metal/atomic-texture-texture1d.slang.2.expected.txt
new file mode 100644
index 000000000..528a4aacf
--- /dev/null
+++ b/tests/metal/atomic-texture-texture1d.slang.2.expected.txt
@@ -0,0 +1,93 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/atomic-texture-texture1d.slang.3.expected.txt b/tests/metal/atomic-texture-texture1d.slang.3.expected.txt
new file mode 100644
index 000000000..528a4aacf
--- /dev/null
+++ b/tests/metal/atomic-texture-texture1d.slang.3.expected.txt
@@ -0,0 +1,93 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/atomic-texture-texture2d.slang b/tests/metal/atomic-texture-texture2d.slang
index b18c96168..6ad659ef0 100644
--- a/tests/metal/atomic-texture-texture2d.slang
+++ b/tests/metal/atomic-texture-texture2d.slang
@@ -1,22 +1,31 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+//TEST(compute, metal):COMPARE_COMPUTE_EX:-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
//METALLIB: @computeMain
+//TEST_INPUT: RWTexture2D(format=R32Uint, size=15, content=one):name uintTexture2D
RWTexture2D<uint> uintTexture2D;
+//TEST_INPUT: RWTexture2D(format=R32Sint, size=15, content=one):name intTexture2D
RWTexture2D<int> intTexture2D;
+//TEST_INPUT: RWTexture2D(format=R32Uint, size=15, content=one, arrayLength=2):name uintTexture2DArray
RWTexture2DArray<uint> uintTexture2DArray;
+//TEST_INPUT: RWTexture2D(format=R32Sint, size=15, content=one, arrayLength=2):name intTexture2DArray
RWTexture2DArray<int> intTexture2DArray;
+//TEST_INPUT: ubuffer(data=[0], stride=1, count=368):out,name outBuffer
+RWStructuredBuffer<int> outBuffer;
+
void test()
{
- int valInt = 1;
- int originalValueInt;
+ int valInt = 3;
+ int originalValueInt = 999;
int compareValueInt = 1;
- uint valUInt = 1;
- uint originalValueUInt;
+ uint valUInt = 3;
+ uint originalValueUInt = 999;
int compareValueUInt = 1;
// Texture2D
@@ -51,37 +60,56 @@ void test()
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
- InterlockedAdd(intTexture2D[0], valInt);
- InterlockedAnd(intTexture2D[0], valInt);
- InterlockedMax(intTexture2D[0], valInt);
- InterlockedMin(intTexture2D[0], valInt);
- InterlockedOr(intTexture2D[0], valInt);
- InterlockedXor(intTexture2D[0], valInt);
- InterlockedAdd(intTexture2D[0], valInt, originalValueInt);
- InterlockedAnd(intTexture2D[0], valInt, originalValueInt);
- InterlockedMax(intTexture2D[0], valInt, originalValueInt);
- InterlockedMin(intTexture2D[0], valInt, originalValueInt);
- InterlockedOr(intTexture2D[0], valInt, originalValueInt);
- InterlockedXor(intTexture2D[0], valInt, originalValueInt);
- InterlockedExchange(intTexture2D[0], valInt, originalValueInt);
- InterlockedCompareExchange(intTexture2D[0], valInt, compareValueInt, originalValueInt);
- InterlockedCompareStore(intTexture2D[0], valUInt, compareValueUInt);
+ int o = 0;
+ int i = 0;
+ InterlockedAdd(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedAnd(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedMax(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedMin(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedOr(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedXor(uintTexture2D[uint2(i++, 0)], valUInt);
+ InterlockedAdd(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedAnd(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMax(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMin(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedOr(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedXor(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedExchange(uintTexture2D[uint2(i++, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareExchange(uintTexture2D[uint2(i++, 0)], valUInt, compareValueUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareStore(uintTexture2D[uint2(i++, 0)], valUInt, compareValueUInt);
- InterlockedAdd(uintTexture2D[0], valUInt);
- InterlockedAnd(uintTexture2D[0], valUInt);
- InterlockedMax(uintTexture2D[0], valUInt);
- InterlockedMin(uintTexture2D[0], valUInt);
- InterlockedOr(uintTexture2D[0], valUInt);
- InterlockedXor(uintTexture2D[0], valUInt);
- InterlockedAdd(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedAnd(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedMax(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedMin(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedOr(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedXor(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedExchange(uintTexture2D[0], valUInt, originalValueUInt);
- InterlockedCompareExchange(uintTexture2D[0], valUInt, compareValueUInt, originalValueUInt);
- InterlockedCompareStore(uintTexture2D[0], valUInt, compareValueUInt);
+ i = 0;
+ InterlockedAdd(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedAnd(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedMax(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedMin(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedOr(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedXor(intTexture2D[uint2(i++, 0)], valInt);
+ InterlockedAdd(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedAnd(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMax(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMin(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedOr(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedXor(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedExchange(intTexture2D[uint2(i++, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareExchange(intTexture2D[uint2(i++, 0)], valInt, compareValueInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareStore(intTexture2D[uint2(i++, 0)], valInt, compareValueUInt);
// Texture2DArray
// METAL: .atomic_fetch_add
@@ -115,37 +143,64 @@ void test()
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
- InterlockedAdd(intTexture2DArray[0], valInt);
- InterlockedAnd(intTexture2DArray[0], valInt);
- InterlockedMax(intTexture2DArray[0], valInt);
- InterlockedMin(intTexture2DArray[0], valInt);
- InterlockedOr(intTexture2DArray[0], valInt);
- InterlockedXor(intTexture2DArray[0], valInt);
- InterlockedAdd(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedAnd(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedMax(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedMin(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedOr(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedXor(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedExchange(intTexture2DArray[0], valInt, originalValueInt);
- InterlockedCompareExchange(intTexture2DArray[0], valInt, compareValueInt, originalValueInt);
- InterlockedCompareStore(intTexture2DArray[0], valUInt, compareValueUInt);
+ i = 0;
+ InterlockedAdd(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedAnd(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedMax(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedMin(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedOr(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedXor(uintTexture2DArray[uint3(i++, 0, 0)], valUInt);
+ InterlockedAdd(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedAnd(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMax(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMin(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedOr(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedXor(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedExchange(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareExchange(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, compareValueUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareStore(uintTexture2DArray[uint3(i++, 0, 0)], valUInt, compareValueUInt);
+
+ i = 0;
+ InterlockedAdd(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedAnd(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedMax(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedMin(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedOr(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedXor(intTexture2DArray[uint3(i++, 0, 0)], valInt);
+ InterlockedAdd(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedAnd(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMax(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMin(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedOr(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedXor(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedExchange(intTexture2DArray[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareExchange(intTexture2DArray[uint3(i++, 0, 0)], valInt, compareValueInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareStore(intTexture2DArray[uint3(i++, 0, 0)], valUInt, compareValueUInt);
- InterlockedAdd(uintTexture2DArray[0], valUInt);
- InterlockedAnd(uintTexture2DArray[0], valUInt);
- InterlockedMax(uintTexture2DArray[0], valUInt);
- InterlockedMin(uintTexture2DArray[0], valUInt);
- InterlockedOr(uintTexture2DArray[0], valUInt);
- InterlockedXor(uintTexture2DArray[0], valUInt);
- InterlockedAdd(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedAnd(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedMax(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedMin(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedOr(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedXor(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedExchange(uintTexture2DArray[0], valUInt, originalValueUInt);
- InterlockedCompareExchange(uintTexture2DArray[0], valUInt, compareValueUInt, originalValueUInt);
- InterlockedCompareStore(uintTexture2DArray[0], valUInt, compareValueUInt);
+ // Copy to output
+ int test_count = i;
+ for (i=0; i<test_count; i++) {
+ outBuffer[o + test_count*0 + i] = uintTexture2D[uint2(i, 0)];
+ outBuffer[o + test_count*1 + i] = intTexture2D[uint2(i, 0)];
+ outBuffer[o + test_count*2 + i] = uintTexture2DArray[uint3(i, 0, 0)];
+ outBuffer[o + test_count*3 + i] = intTexture2DArray[uint3(i, 0, 0)];
+ }
}
[numthreads(1, 1, 1)]
diff --git a/tests/metal/atomic-texture-texture2d.slang.2.expected.txt b/tests/metal/atomic-texture-texture2d.slang.2.expected.txt
new file mode 100644
index 000000000..528a4aacf
--- /dev/null
+++ b/tests/metal/atomic-texture-texture2d.slang.2.expected.txt
@@ -0,0 +1,93 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/atomic-texture-texture2d.slang.3.expected.txt b/tests/metal/atomic-texture-texture2d.slang.3.expected.txt
new file mode 100644
index 000000000..528a4aacf
--- /dev/null
+++ b/tests/metal/atomic-texture-texture2d.slang.3.expected.txt
@@ -0,0 +1,93 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/atomic-texture-texture3d.slang b/tests/metal/atomic-texture-texture3d.slang
index 755b941da..054ca8fe7 100644
--- a/tests/metal/atomic-texture-texture3d.slang
+++ b/tests/metal/atomic-texture-texture3d.slang
@@ -1,18 +1,26 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+//TEST(compute, metal):COMPARE_COMPUTE_EX:-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
//METALLIB: @computeMain
+//TEST_INPUT: RWTexture3D(format=R32Uint, size=15, content=one):name uintTexture3D
RWTexture3D<uint> uintTexture3D;
+//TEST_INPUT: RWTexture3D(format=R32Sint, size=15, content=one):name intTexture3D
RWTexture3D<int> intTexture3D;
+
+//TEST_INPUT: ubuffer(data=[0], stride=1, count=184):out,name outBuffer
+RWStructuredBuffer<int> outBuffer;
+
void test()
{
- int valInt = 1;
- int originalValueInt;
+ int valInt = 3;
+ int originalValueInt = 999;
int compareValueInt = 1;
- uint valUInt = 1;
- uint originalValueUInt;
+ uint valUInt = 3;
+ uint originalValueUInt = 999;
int compareValueUInt = 1;
// Texture3D
@@ -47,38 +55,64 @@ void test()
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
- InterlockedAdd(intTexture3D[0], valInt);
- InterlockedAnd(intTexture3D[0], valInt);
- InterlockedMax(intTexture3D[0], valInt);
- InterlockedMin(intTexture3D[0], valInt);
- InterlockedOr(intTexture3D[0], valInt);
- InterlockedXor(intTexture3D[0], valInt);
- InterlockedAdd(intTexture3D[0], valInt, originalValueInt);
- InterlockedAnd(intTexture3D[0], valInt, originalValueInt);
- InterlockedMax(intTexture3D[0], valInt, originalValueInt);
- InterlockedMin(intTexture3D[0], valInt, originalValueInt);
- InterlockedOr(intTexture3D[0], valInt, originalValueInt);
- InterlockedXor(intTexture3D[0], valInt, originalValueInt);
- InterlockedExchange(intTexture3D[0], valInt, originalValueInt);
- InterlockedCompareExchange(intTexture3D[0], valInt, compareValueInt, originalValueInt);
- InterlockedCompareStore(intTexture3D[0], valUInt, compareValueUInt);
+ int o = 0;
+ int i = 0;
+ InterlockedAdd(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedAnd(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedMax(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedMin(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedOr(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedXor(uintTexture3D[uint3(i++, 0, 0)], valUInt);
+ InterlockedAdd(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedAnd(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMax(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedMin(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedOr(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedXor(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedExchange(uintTexture3D[uint3(i++, 0, 0)], valUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareExchange(uintTexture3D[uint3(i++, 0, 0)], valUInt, compareValueUInt, originalValueUInt);
+ outBuffer[o++] = originalValueUInt;
+ InterlockedCompareStore(uintTexture3D[uint3(i++, 0, 0)], valUInt, compareValueUInt);
+
+ i = 0;
+ InterlockedAdd(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedAnd(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedMax(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedMin(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedOr(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedXor(intTexture3D[uint3(i++, 0, 0)], valInt);
+ InterlockedAdd(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedAnd(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMax(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedMin(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedOr(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedXor(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedExchange(intTexture3D[uint3(i++, 0, 0)], valInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareExchange(intTexture3D[uint3(i++, 0, 0)], valInt, compareValueInt, originalValueInt);
+ outBuffer[o++] = originalValueInt;
+ InterlockedCompareStore(intTexture3D[uint3(i++, 0, 0)], valInt, compareValueUInt);
- InterlockedAdd(uintTexture3D[0], valUInt);
- InterlockedAnd(uintTexture3D[0], valUInt);
- InterlockedMax(uintTexture3D[0], valUInt);
- InterlockedMin(uintTexture3D[0], valUInt);
- InterlockedOr(uintTexture3D[0], valUInt);
- InterlockedXor(uintTexture3D[0], valUInt);
- InterlockedAdd(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedAnd(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedMax(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedMin(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedOr(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedXor(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedExchange(uintTexture3D[0], valUInt, originalValueUInt);
- InterlockedCompareExchange(uintTexture3D[0], valUInt, compareValueUInt, originalValueUInt);
- InterlockedCompareStore(uintTexture3D[0], valUInt, compareValueUInt);
+ // Copy to output
+ int test_count = i;
+ for (i=0; i<test_count; i++) {
+ outBuffer[o + test_count*0 + i] = uintTexture3D[uint3(i, 0, 0)];
+ outBuffer[o + test_count*1 + i] = intTexture3D[uint3(i, 0, 0)];
+ }
}
[numthreads(1, 1, 1)]
diff --git a/tests/metal/atomic-texture-texture3d.slang.2.expected.txt b/tests/metal/atomic-texture-texture3d.slang.2.expected.txt
new file mode 100644
index 000000000..7298de63b
--- /dev/null
+++ b/tests/metal/atomic-texture-texture3d.slang.2.expected.txt
@@ -0,0 +1,47 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/atomic-texture-texture3d.slang.3.expected.txt b/tests/metal/atomic-texture-texture3d.slang.3.expected.txt
new file mode 100644
index 000000000..7298de63b
--- /dev/null
+++ b/tests/metal/atomic-texture-texture3d.slang.3.expected.txt
@@ -0,0 +1,47 @@
+type: int32_t
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
+4
+1
+3
+1
+3
+2
+4
+1
+3
+1
+3
+2
+3
+1
+1
diff --git a/tests/metal/barrier.slang b/tests/metal/barrier.slang
index 86e4265be..366abe1d0 100644
--- a/tests/metal/barrier.slang
+++ b/tests/metal/barrier.slang
@@ -1,18 +1,24 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
-// CHECK: threadgroup_barrier
+// METAL: threadgroup_barrier
-// CHECK-ASM: define void @computeMain
+// METALLIB: define void @computeMain
+//TEST_INPUT: ubuffer(data=[0 0 0], stride=1):out,name outputBuffer
RWStructuredBuffer<float> outputBuffer;
[numthreads(1,1,1)]
void computeMain()
{
+ // BUF: 1.0
outputBuffer[0] = 1;
GroupMemoryBarrierWithGroupSync();
+ // BUF: 2.0
outputBuffer[1] = 2;
AllMemoryBarrierWithGroupSync();
+ // BUF: 3.0
outputBuffer[2] = 3;
-} \ No newline at end of file
+}
diff --git a/tests/metal/barycentrics.slang b/tests/metal/barycentrics.slang
index 105ea22ed..19c413888 100644
--- a/tests/metal/barycentrics.slang
+++ b/tests/metal/barycentrics.slang
@@ -1,8 +1,8 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
-// CHECK: {{\[\[}}barycentric_coord{{\]\]}}
-// CHECK-ASM: !"air.barycentric_coord"
+// METAL: {{\[\[}}barycentric_coord{{\]\]}}
+// METALLIB: !"air.barycentric_coord"
[shader("fragment")]
float4 fragment_main(float4 pos: SV_Position, float3 barycentrics: SV_Barycentrics)
diff --git a/tests/metal/byte-address-buffer.slang b/tests/metal/byte-address-buffer.slang
index c0fb6b6b2..b5d806e20 100644
--- a/tests/metal/byte-address-buffer.slang
+++ b/tests/metal/byte-address-buffer.slang
@@ -1,9 +1,15 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE_EX:-metal -compute -output-using-type
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type
+// VK test disabled due to unhandled global inst
+// TODO: github issue #8480
+
+//TEST_INPUT:ubuffer(data=[0xfffefdfc 0xfbfaf9f8 0xf7f6f5f4 0xf3f2f1f0 0xefeeedec 0xebeae9e8 0xe7e6e5e4 0xe3e2e1e0 0xdfdedddc 0xdbdad9d8 0xd7d6d5d4 0xd3d2d1d0 0xcfcecdcc 0xcbcac9c8 0xc7c6c5c4 0xc3c2c1c0 0xbfbebdbc 0xbbbab9b8 0xb7b6b5b4 0xb3b2b1b0 0xafaeadac 0xabaaa9a8 0xa7a6a5a4 0xa3a2a1a0 0x9f9e9d9c 0x9b9a9998 0x97969594 0x93929190 0x8f8e8d8c 0x8b8a8988 0x87868584 0x83828180 0x7f7e7d7c 0x7b7a7978 0x77767574 0x73727170 0x6f6e6d6c 0x6b6a6968 0x67666564 0x63626160 0x5f5e5d5c 0x5b5a5958 0x57565554 0x53525150 0x4f4e4d4c 0x4b4a4948 0x47464544 0x43424140 0x3f3e3d3c 0x3b3a3938 0x37363534 0x33323130 0x2f2e2d2c 0x2b2a2928 0x27262524 0x23222120 0x1f1e1d1c 0x1b1a1918 0x17161514 0x13121110 0x0f0e0d0c 0x0b0a0908 0x07060504 0x03020100 0xfffefdfc 0xfbfaf9f8 0xf7f6f5f4 0xf3f2f1f0 0xefeeedec 0xebeae9e8 0xe7e6e5e4 0xe3e2e1e0 0xdfdedddc 0xdbdad9d8 0xd7d6d5d4]):out,name=buffer
RWByteAddressBuffer buffer;
-// CHECK-ASM: define void @main_kernel
+// METALLIB: define void @computeMain
struct TestStruct
{
@@ -15,34 +21,35 @@ struct TestStruct
}
[numthreads(1,1,1)]
-void main_kernel(uint3 tid: SV_DispatchThreadID)
+[shader("compute")]
+void computeMain(uint3 tid: SV_DispatchThreadID)
{
- // CHECK: uint [[WORD0:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(0U)>>2]);
- // CHECK: uchar [[A:[a-zA-Z0-9_]+]] = uchar(([[WORD0]] >> 0U) & 255U);
- // CHECK: uint [[WORD1:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(0U)>>2]);
- // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort(([[WORD1]] >> 16U) & 65535U));
+ // METAL: uint [[WORD0:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(0U)>>2]);
+ // METAL: uchar [[A:[a-zA-Z0-9_]+]] = uchar(([[WORD0]] >> 0U) & 255U);
+ // METAL: uint [[WORD1:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(0U)>>2]);
+ // METAL: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort(([[WORD1]] >> 16U) & 65535U));
- // CHECK: {{.*}}[(128U)>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | (uint([[A]]) << 0U));
- // CHECK: {{.*}}[(128U)>>2] = as_type<uint32_t>(({{.*}} & 65535U) | (uint(as_type<ushort>([[H]])) << 16U));
+ // METAL: {{.*}}[(128U)>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | (uint([[A]]) << 0U));
+ // METAL: {{.*}}[(128U)>>2] = as_type<uint32_t>(({{.*}} & 65535U) | (uint(as_type<ushort>([[H]])) << 16U));
buffer.Store(128, buffer.Load<TestStruct>(0));
- // CHECK: {{.*}}[(256U)>>2] = as_type<uint32_t>(4294967295U);
- // CHECK: {{.*}}[(260U)>>2] = as_type<uint32_t>(4294967295U);
+ // METAL: {{.*}}[(256U)>>2] = as_type<uint32_t>(4294967295U);
+ // METAL: {{.*}}[(260U)>>2] = as_type<uint32_t>(4294967295U);
int64_t i64 = -1;
buffer.Store(256, i64);
- // CHECK: {{.*}}[(264U)>>2] = as_type<uint32_t>(123U);
- // CHECK: {{.*}}[(268U)>>2] = as_type<uint32_t>(0U);
+ // METAL: {{.*}}[(264U)>>2] = as_type<uint32_t>(123U);
+ // METAL: {{.*}}[(268U)>>2] = as_type<uint32_t>(0U);
uint64_t u64 = 123;
buffer.Store(264, u64);
int64_t* ptr = Ptr<int64_t>(0xFF);
- // CHECK: {{.*}}[(272U)>>2] = as_type<uint32_t>({{.*}});
- // CHECK: {{.*}}[(276U)>>2] = as_type<uint32_t>({{.*}});
+ // METAL: {{.*}}[(272U)>>2] = as_type<uint32_t>({{.*}});
+ // METAL: {{.*}}[(276U)>>2] = as_type<uint32_t>({{.*}});
buffer.Store(272, ptr);
- // CHECK: {{.*}}[(280U)>>2] = as_type<uint32_t>(4294967295U);
- // CHECK: {{.*}}[(284U)>>2] = as_type<uint32_t>(4294967295U);
+ // METAL: {{.*}}[(280U)>>2] = as_type<uint32_t>(4294967295U);
+ // METAL: {{.*}}[(284U)>>2] = as_type<uint32_t>(4294967295U);
uintptr_t uintptr_val = (uintptr_t)-1;
buffer.Store(280, uintptr_val);
}
diff --git a/tests/metal/byte-address-buffer.slang.2.expected.txt b/tests/metal/byte-address-buffer.slang.2.expected.txt
new file mode 100644
index 000000000..65de45e75
--- /dev/null
+++ b/tests/metal/byte-address-buffer.slang.2.expected.txt
@@ -0,0 +1,75 @@
+FFFEFDFC
+FBFAF9F8
+F7F6F5F4
+F3F2F1F0
+EFEEEDEC
+EBEAE9E8
+E7E6E5E4
+E3E2E1E0
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
+D3D2D1D0
+CFCECDCC
+CBCAC9C8
+C7C6C5C4
+C3C2C1C0
+BFBEBDBC
+BBBAB9B8
+B7B6B5B4
+B3B2B1B0
+AFAEADAC
+ABAAA9A8
+A7A6A5A4
+A3A2A1A0
+9F9E9D9C
+9B9A9998
+97969594
+93929190
+8F8E8D8C
+8B8A8988
+87868584
+83828180
+FFFE7DFC
+FBFAF9F8
+F7F6F5F4
+F3F2F1F0
+EFEEEDEC
+EBEAE9E8
+E7E6E5E4
+E3E2E1E0
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
+D3D2D1D0
+CFCECDCC
+CBCAC9C8
+C7C6C5C4
+C3C2C1C0
+BFBEBDBC
+BBBAB9B8
+37363534
+33323130
+2F2E2D2C
+2B2A2928
+27262524
+23222120
+1F1E1D1C
+1B1A1918
+17161514
+13121110
+F0E0D0C
+B0A0908
+7060504
+3020100
+FFFFFFFF
+FFFFFFFF
+7B
+0
+FF
+0
+FFFFFFFF
+FFFFFFFF
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
diff --git a/tests/metal/byte-address-buffer.slang.3.expected.txt b/tests/metal/byte-address-buffer.slang.3.expected.txt
new file mode 100644
index 000000000..65de45e75
--- /dev/null
+++ b/tests/metal/byte-address-buffer.slang.3.expected.txt
@@ -0,0 +1,75 @@
+FFFEFDFC
+FBFAF9F8
+F7F6F5F4
+F3F2F1F0
+EFEEEDEC
+EBEAE9E8
+E7E6E5E4
+E3E2E1E0
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
+D3D2D1D0
+CFCECDCC
+CBCAC9C8
+C7C6C5C4
+C3C2C1C0
+BFBEBDBC
+BBBAB9B8
+B7B6B5B4
+B3B2B1B0
+AFAEADAC
+ABAAA9A8
+A7A6A5A4
+A3A2A1A0
+9F9E9D9C
+9B9A9998
+97969594
+93929190
+8F8E8D8C
+8B8A8988
+87868584
+83828180
+FFFE7DFC
+FBFAF9F8
+F7F6F5F4
+F3F2F1F0
+EFEEEDEC
+EBEAE9E8
+E7E6E5E4
+E3E2E1E0
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
+D3D2D1D0
+CFCECDCC
+CBCAC9C8
+C7C6C5C4
+C3C2C1C0
+BFBEBDBC
+BBBAB9B8
+37363534
+33323130
+2F2E2D2C
+2B2A2928
+27262524
+23222120
+1F1E1D1C
+1B1A1918
+17161514
+13121110
+F0E0D0C
+B0A0908
+7060504
+3020100
+FFFFFFFF
+FFFFFFFF
+7B
+0
+FF
+0
+FFFFFFFF
+FFFFFFFF
+DFDEDDDC
+DBDAD9D8
+D7D6D5D4
diff --git a/tests/metal/depth-texture.slang b/tests/metal/depth-texture.slang
index ac15b3f1a..be7bc2f5d 100644
--- a/tests/metal/depth-texture.slang
+++ b/tests/metal/depth-texture.slang
@@ -1,12 +1,19 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metallib
-//CHECK: sample_compare_depth_2d
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
+
+//TEST_INPUT: Texture2D(size=4, format=D32Float, content = one):name texture
Texture2D texture;
+//TEST_INPUT: Sampler(depthCompare):name sampler
SamplerComparisonState sampler;
+//TEST_INPUT: ubuffer(data=[0], stride=1):out,name output
RWStructuredBuffer<float> output;
[numthreads(1,1,1)]
void computeMain()
{
+ // METALLIB: sample_compare_depth_2d
+ // BUF: 1.000000
output[0] = texture.SampleCmpLevelZero(sampler, float2(0, 0), 0);
-} \ No newline at end of file
+}
diff --git a/tests/metal/discard.slang b/tests/metal/discard.slang
index 7c2622561..b670e462a 100644
--- a/tests/metal/discard.slang
+++ b/tests/metal/discard.slang
@@ -1,9 +1,9 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
-// CHECK: discard_fragment();
+// METAL: discard_fragment();
-// CHECK-ASM: define {{.*}} @main_fragment1
+// METALLIB: define {{.*}} @main_fragment1
struct VOut
{
@@ -19,4 +19,4 @@ float4 main_fragment1(VOut fragmentIn)
if (fragmentIn.vertexColor.x == 0.0)
discard;
return fragmentIn.vertexColor;
-} \ No newline at end of file
+}
diff --git a/tests/metal/empty-struct-remove.slang b/tests/metal/empty-struct-remove.slang
index 5ac1ccb69..0ea926953 100644
--- a/tests/metal/empty-struct-remove.slang
+++ b/tests/metal/empty-struct-remove.slang
@@ -1,6 +1,7 @@
-
//TEST:SIMPLE(filecheck=LIB):-target metallib -entry computeMain -stage compute
//TEST:SIMPLE(filecheck=METAL):-target metal -entry computeMain -stage compute
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
// METAL-NOT: struct emptyStruct
struct emptyStruct
@@ -20,6 +21,7 @@ struct MyStruct
emptyStruct e;
}
+//TEST_INPUT: set param = new MyStruct{ out ubuffer(data=[0]), 5, {}}
ParameterBlock<MyStruct> param;
// LIB: @computeMain
@@ -29,5 +31,6 @@ void computeMain(
uint tid: SV_DispatchThreadID,
)
{
+ // BUF: 5
param.set();
}
diff --git a/tests/metal/explicit-location.slang b/tests/metal/explicit-location.slang
index 35930cfce..5f7a281cf 100644
--- a/tests/metal/explicit-location.slang
+++ b/tests/metal/explicit-location.slang
@@ -1,6 +1,11 @@
//TEST:SIMPLE(filecheck=MTL): -target metal
+//TEST:SIMPLE(filecheck=LIB): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -entry vertMain -stage vertex
+
+// LIB-NOT: error :
+// LIB: @vertMain
+
// MTL: attribute(3)
// WGSL: @location(3)
@@ -14,4 +19,4 @@ struct Vertex
float4 vertMain(Vertex vin) : SV_Position
{
return vin.pos + vin.uv.x;
-} \ No newline at end of file
+}
diff --git a/tests/metal/groupshared.slang b/tests/metal/groupshared.slang
index 4d1f6ecac..d5fe3107e 100644
--- a/tests/metal/groupshared.slang
+++ b/tests/metal/groupshared.slang
@@ -1,6 +1,9 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
+//TEST_INPUT: ubuffer(data=[2.0], stride=1):out,name outputBuffer
uniform RWStructuredBuffer<float> outputBuffer;
struct MyBlock
@@ -14,17 +17,18 @@ groupshared int myArr[16];
void func(float v)
{
+ // BUF: 0.000000
outputBuffer[0] = myArr[0];
}
-// CHECK: array<int, int(16)> threadgroup* myArr{{.*}};
-// CHECK: {{\[\[}}kernel{{\]\]}} void main_kernel
-// CHECK: threadgroup array<int, int(16)> myArr{{.*}};
-// CHECK: (&kernelContext{{.*}})->myArr{{.*}} = &myArr{{.*}};
-// CHECK-ASM: define void @main_kernel
+// METAL: array<int, int(16)> threadgroup* myArr{{.*}};
+// METAL: {{\[\[}}kernel{{\]\]}} void computeMain
+// METAL: threadgroup array<int, int(16)> myArr{{.*}};
+// METAL: (&kernelContext{{.*}})->myArr{{.*}} = &myArr{{.*}};
+// METALLIB: define void @computeMain
[numthreads(1,1,1)]
-void main_kernel(uint3 tid: SV_DispatchThreadID)
+void computeMain(uint3 tid: SV_DispatchThreadID)
{
myArr[tid.x] = tid.x;
func(3.0f);
diff --git a/tests/metal/math.slang b/tests/metal/math.slang
index 288d6137c..cf5a4a041 100644
--- a/tests/metal/math.slang
+++ b/tests/metal/math.slang
@@ -6,10 +6,12 @@
//TEST:SIMPLE(filecheck=CUDA): -stage compute -entry computeMain -target cuda
//TEST:SIMPLE(filecheck=CPP): -stage compute -entry computeMain -target cpp
-//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type -emit-spirv-via-glsl
-//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type -emit-spirv-directly
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -output-using-type -emit-spirv-via-glsl
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -output-using-type -emit-spirv-directly
//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -output-using-type -xslang -DMETAL_COMPUTE
+
//TEST_INPUT:ubuffer(data=[0 1 -1], stride=4):name=inputBuffer
RWStructuredBuffer<int> inputBuffer;
@@ -21,6 +23,31 @@ RWStructuredBuffer<int> outputBuffer;
// It is unclear why "nextafter" is not working for Metal.
#define TEST_WHEN_nextafter_WORKS 0
+// NOTE: This test is mainly equality comparisons of math functions results
+// against a precise expected value, but the Metal spec defines a minimum
+// accuracy for many of these math functions such that a range of results may
+// be allowed, presumably corresponding to different generations of hardware.
+// Exact comparisons are preferred here for simplicity's sake, but in cases
+// where, e.g., an M1 may yield a different result from an M4, this test checks
+// that the value falls within the documented range instead.
+
+__generic<T:__BuiltinFloatingPointType>
+bool fuzzyCompare(const T value, const T expected, const T epsilon)
+{
+ return
+ value <= (expected + epsilon) &&
+ value >= (expected - epsilon);
+}
+
+__generic<T:__BuiltinFloatingPointType, let N : int>
+bool fuzzyCompare(const vector<T,N> value, const vector<T,N> expected, const vector<T,N> epsilon)
+{
+ return all(
+ value <= (expected + epsilon) &&
+ value >= (expected - epsilon)
+ );
+}
+
__generic<T:__BuiltinFloatingPointType>
bool Test_Scalar()
{
@@ -30,6 +57,8 @@ bool Test_Scalar()
const int zeroInt = int(inputBuffer[0]);
+ const T EPS_E2N13 = T(0.0001220703125); // 2^-13
+
T outFloat1, outFloat2;
int outInt;
@@ -63,7 +92,7 @@ bool Test_Scalar()
// METAL: atan2(
// METALLIB: atan2.f32
- && zero == atan2<T>(zero, zero)
+ && zero == atan2<T>(zero, one)
// METAL: atanh(
// METALLIB: atanh.f32
@@ -87,7 +116,7 @@ bool Test_Scalar()
// METAL: cospi(
// METALLIB: cospi.f32
- && one == cospi<T>(zero)
+ && fuzzyCompare<T>(cospi<T>(zero), one, EPS_E2N13)
// METAL: divide(
// METALLIB: fdiv
@@ -258,6 +287,8 @@ bool Test_Vector()
const vector<int,N> zeroInt = int(inputBuffer[0]);
+ const vector<T,N> EPS_E2N13 = T(0.0001220703125); // 2^-13
+
vector<T,N> outFloat1, outFloat2;
vector<int,N> outInt;
@@ -291,7 +322,7 @@ bool Test_Vector()
// METAL: atan2(
// METAL-NOT: atan2(
- && zero == atan2<T>(zero, zero)
+ && zero == atan2<T>(zero, one)
// METAL: atanh(
// METAL-NOT: atanh(
@@ -315,7 +346,7 @@ bool Test_Vector()
// METAL: cospi(
// METAL-NOT: cospi(
- && one == cospi<T>(zero)
+ && fuzzyCompare<T,N>(cospi<T>(zero), one, EPS_E2N13)
// METAL: divide(
// METAL-NOT: divide(
diff --git a/tests/metal/matrix-bool-lowering.slang b/tests/metal/matrix-bool-lowering.slang
index 4248bb573..79537ac24 100644
--- a/tests/metal/matrix-bool-lowering.slang
+++ b/tests/metal/matrix-bool-lowering.slang
@@ -1,6 +1,7 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -mtl -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -mtl -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -vk -shaderobj
//TEST_INPUT:ubuffer(data=[1 0], stride=4):name inputBuffer
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
@@ -83,37 +84,37 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
// Store results
outputBuffer[0] = val1;
- // CHECK: 1
+ // BUF: 1
outputBuffer[1] = val2;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[2] = row.x;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[3] = row.y;
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[4] = row3.y;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[5] = not_mat[0][0];
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[6] = and_mat[0][0];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[7] = mat1[0][1];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[8] = mat3[0][1];
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[9] = anded;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[10] = wrapper.mat1[0][0] || wrapper.mat2[0][0];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[11] = test_all_true;
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[12] = test_all_false;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[13] = test_all_mixed;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[14] = test_any_true;
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[15] = test_any_false;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[16] = test_any_mixed;
- // CHECK-NEXT: 1
-} \ No newline at end of file
+ // BUF-NEXT: 1
+}
diff --git a/tests/metal/matrix-integer-lowering.slang b/tests/metal/matrix-integer-lowering.slang
index 04aec5a7c..08d3de886 100644
--- a/tests/metal/matrix-integer-lowering.slang
+++ b/tests/metal/matrix-integer-lowering.slang
@@ -1,7 +1,9 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain -DTYPE=int
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain -DTYPE=int
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -output-using-type -compute -mtl -shaderobj -xslang -DTYPE=int
-//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -output-using-type -compute -mtl -shaderobj -xslang -DTYPE=uint
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -output-using-type -compute -mtl -shaderobj -xslang -DTYPE=int
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -output-using-type -compute -mtl -shaderobj -xslang -DTYPE=uint
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -output-using-type -compute -vk -shaderobj -xslang -DTYPE=int
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -output-using-type -compute -vk -shaderobj -xslang -DTYPE=uint
#ifndef TYPE
#define TYPE int
@@ -116,87 +118,87 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
// Store results
outputBuffer[0] = val1;
- // CHECK: 1
+ // BUF: 1
outputBuffer[1] = val2;
- // CHECK-NEXT: 8
+ // BUF-NEXT: 8
outputBuffer[2] = row.x;
- // CHECK-NEXT: 3
+ // BUF-NEXT: 3
outputBuffer[3] = row.y;
- // CHECK-NEXT: 4
+ // BUF-NEXT: 4
outputBuffer[4] = row3.y;
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[5] = mat_scalar[0][0];
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[6] = mat_add[0][0];
- // CHECK-NEXT: 3
+ // BUF-NEXT: 3
outputBuffer[7] = mat_sub[0][0];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[8] = mat_mul[1][1];
- // CHECK-NEXT: 28
+ // BUF-NEXT: 28
outputBuffer[9] = added;
- // CHECK-NEXT: 10
+ // BUF-NEXT: 10
outputBuffer[10] = wrapper.mat1[0][0] * wrapper.mat2[0][0];
- // CHECK-NEXT: 5
+ // BUF-NEXT: 5
// Matrix intrinsic operation results
outputBuffer[11] = det2x2;
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[12] = det3x3;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[13] = mat_min[0][0];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[14] = mat_min[1][1];
- // CHECK-NEXT: 4
+ // BUF-NEXT: 4
outputBuffer[15] = mat_max[0][0];
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[16] = mat_max[1][1];
- // CHECK-NEXT: 7
+ // BUF-NEXT: 7
outputBuffer[17] = all_nonzero;
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[18] = all_zero;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[19] = any_nonzero;
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[20] = any_zero;
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[21] = trans2x2[0][0];
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[22] = trans2x2[1][0];
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[23] = trans2x3[0][0];
- // CHECK-NEXT: 5
+ // BUF-NEXT: 5
// Bit shift operation results
outputBuffer[24] = left_shift[0][0];
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[25] = left_shift[0][1];
- // CHECK-NEXT: 4
+ // BUF-NEXT: 4
outputBuffer[26] = right_shift[1][0];
- // CHECK-NEXT: 2
+ // BUF-NEXT: 2
outputBuffer[27] = right_shift[1][1];
- // CHECK-NEXT: 4
+ // BUF-NEXT: 4
// Comparison operation results (bool matrices cast to TYPE)
outputBuffer[28] = TYPE(less_than[0][0]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[29] = TYPE(less_than[0][1]);
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[30] = TYPE(greater_than[0][1]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[31] = TYPE(greater_than[1][1]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[32] = TYPE(less_equal[0][0]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[33] = TYPE(less_equal[0][1]);
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[34] = TYPE(greater_equal[0][1]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[35] = TYPE(greater_equal[1][0]);
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[36] = TYPE(equal_to[0][0]);
- // CHECK-NEXT: 0
+ // BUF-NEXT: 0
outputBuffer[37] = TYPE(negated[0][0] == expectedBuffer[0]);
- // CHECK-NEXT: 1
+ // BUF-NEXT: 1
outputBuffer[38] = TYPE(negated[1][1] == expectedBuffer[1]);
- // CHECK-NEXT: 1
-} \ No newline at end of file
+ // BUF-NEXT: 1
+}
diff --git a/tests/metal/matrix-negate.slang b/tests/metal/matrix-negate.slang
index f6ae6816f..f8859dfd3 100644
--- a/tests/metal/matrix-negate.slang
+++ b/tests/metal/matrix-negate.slang
@@ -1,11 +1,17 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk
-// CHECK: (matrix<float,int(4),int(4)>{{.*}}(0) -
+// METAL: (matrix<float,int(4),int(4)>{{.*}}(0) -
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name output
RWStructuredBuffer<float4> output;
[numthreads(1,1,1)]
void computeMain(uniform float4x4 m)
{
+ // This test checks for negative zero, so we need to do a hex comparison
+ // instead of a float comparison.
+ // BUF-COUNT-4: 80000000
output[0] = (-m)[0];
-} \ No newline at end of file
+}
diff --git a/tests/metal/metal-pointer-params.slang b/tests/metal/metal-pointer-params.slang
index 6bb7114ee..21e3ee231 100644
--- a/tests/metal/metal-pointer-params.slang
+++ b/tests/metal/metal-pointer-params.slang
@@ -1,21 +1,21 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal -stage compute -entry computeMain
-//TEST:SIMPLE(filecheck=CHK_AIR): -target metallib -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=8):out,name=outputBuffer
RWStructuredBuffer<uint64_t> outputBuffer;
-//CHECK: ulong{{.*}}device{{ *\*}} a
-//CHECK-NEXT: long{{.*}}device{{ *\*}} b
-//CHECK-NEXT: uint{{.*}}device{{ *\*}} c
-//CHECK-NEXT: int{{.*}}device{{ *\*}} d
-//CHECK-NEXT: float{{.*}}device{{ *\*}} e
+//METAL: ulong{{.*}}device{{ *\*}} a
+//METAL-NEXT: long{{.*}}device{{ *\*}} b
+//METAL-NEXT: uint{{.*}}device{{ *\*}} c
+//METAL-NEXT: int{{.*}}device{{ *\*}} d
+//METAL-NEXT: float{{.*}}device{{ *\*}} e
// "indirect_argument" means a pointer
-//CHK_AIR: !"ulong", !"a{{[^"]*}}", !"air.indirect_argument"
-//CHK_AIR: !"long", !"b{{[^"]*}}", !"air.indirect_argument"
-//CHK_AIR: !"uint", !"c{{[^"]*}}", !"air.indirect_argument"
-//CHK_AIR: !"int", !"d{{[^"]*}}", !"air.indirect_argument"
-//CHK_AIR: !"float", !"e{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"ulong", !"a{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"long", !"b{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"uint", !"c{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"int", !"d{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"float", !"e{{[^"]*}}", !"air.indirect_argument"
[numthreads(1,1,1)]
void computeMain(uniform uint64_t* a, uniform int64_t* b, uniform uint32_t* c, uniform int32_t* d, uniform float* e)
diff --git a/tests/metal/metal-pointer-uniform.slang b/tests/metal/metal-pointer-uniform.slang
index 4a0ddb8fd..6c4e9d415 100644
--- a/tests/metal/metal-pointer-uniform.slang
+++ b/tests/metal/metal-pointer-uniform.slang
@@ -1,9 +1,9 @@
-//TEST:SIMPLE(filecheck=CHECK_MTL): -target metal -stage compute -entry computeMain
-//TEST:SIMPLE(filecheck=CHECK_AIR): -target metallib -stage compute -entry computeMain
-//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly
-//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal -render-features argument-buffer-tier-2
-//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -cuda
-//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu
+//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+//TEST:COMPARE_COMPUTE(filecheck-buffer=BUF): -vk -emit-spirv-directly
+//TEST:COMPARE_COMPUTE(filecheck-buffer=BUF): -metal -render-features argument-buffer-tier-2
+//TEST:COMPARE_COMPUTE(filecheck-buffer=BUF): -cuda
+//TEST:COMPARE_COMPUTE(filecheck-buffer=BUF): -cpu
// This reproduces the specific case that was failing where uniform pointers
// are used for buffer copy operations with array indexing targeting Metal.
@@ -11,10 +11,10 @@
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
-//CHECK_MTL: int{{.*}}device{{ *\*}} src
+//METAL: int{{.*}}device{{ *\*}} src
// "indirect_argument" means a pointer
-//CHECK_AIR: !"int", !"src{{[^"]*}}", !"air.indirect_argument"
+//METALLIB: !"int", !"src{{[^"]*}}", !"air.indirect_argument"
//TEST_INPUT: set src = ubuffer(data=[1 2 3 4 5 6 7 8],stride=4);
uniform int* src;
@@ -27,7 +27,7 @@ void computeMain(uint3 threadID : SV_DispatchThreadID)
outputBuffer[threadID.x] = input;
}
-//CHECK:1
-//CHECK-NEXT:2
-//CHECK-NEXT:3
-//CHECK-NEXT:4
+//BUF:1
+//BUF-NEXT:2
+//BUF-NEXT:3
+//BUF-NEXT:4
diff --git a/tests/metal/multi-entry-point-params.slang b/tests/metal/multi-entry-point-params.slang
index 11aefe267..059d5e82a 100644
--- a/tests/metal/multi-entry-point-params.slang
+++ b/tests/metal/multi-entry-point-params.slang
@@ -1,4 +1,5 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal -fvk-use-entrypoint-name
+//TEST:SIMPLE(filecheck=METAL): -target metal -fvk-use-entrypoint-name
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib -fvk-use-entrypoint-name
struct FirstStruct {
uint a;
@@ -27,7 +28,8 @@ RWStructuredBuffer<uint> outBuffer;
// - Binding offset for global params in global scope are the same for each generated entry point.
//
-// CHECK: main1({{.*}}globalScopeBuffer{{.*}}buffer(0)]], FirstStruct{{.*}}buffer(2)]], SecondStruct{{.*}}buffer(3)]], float{{.*}}buffer(4)]])
+// METAL: main1({{.*}}globalScopeBuffer{{.*}}buffer(0)]], FirstStruct{{.*}}buffer(2)]], SecondStruct{{.*}}buffer(3)]], float{{.*}}buffer(4)]])
+// METALLIB: @main1
[shader("compute")]
[numthreads(5, 1, 1)]
void main1(
@@ -41,9 +43,10 @@ void main1(
}
-// CHECK-NOT: FirstStruct
-// CHECK-NOT: SecondStruct
-// CHECK: main2({{.*}}globalScopeBuffer{{.*}}buffer(0)]], ThirdStruct{{.*}}buffer(5)]], FourthStruct{{.*}}buffer(6)]])
+// METAL-NOT: FirstStruct
+// METAL-NOT: SecondStruct
+// METAL: main2({{.*}}globalScopeBuffer{{.*}}buffer(0)]], ThirdStruct{{.*}}buffer(5)]], FourthStruct{{.*}}buffer(6)]])
+// METALLIB: @main2
[shader("compute")]
[numthreads(5, 1, 1)]
void main2(
diff --git a/tests/metal/nested-parameter-block-reflection.slang b/tests/metal/nested-parameter-block-reflection.slang
index 91c07b9c8..b3db21bae 100644
--- a/tests/metal/nested-parameter-block-reflection.slang
+++ b/tests/metal/nested-parameter-block-reflection.slang
@@ -1,25 +1,28 @@
-//TEST:REFLECTION(filecheck=CHECK): -target metal
+//TEST:REFLECTION(filecheck=METAL): -target metal
+//TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -slang -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -slang -compute -output-using-type
+// METAL: "name": "gParams",
+// METAL: "binding": {"kind": "constantBuffer", "index": 0},
-// CHECK: "name": "gParams",
-// CHECK: "binding": {"kind": "constantBuffer", "index": 0},
-
-// CHECK:"name": "pdata",
-// CHECK:"binding": {"kind": "uniform", "offset": 0, "size": 16, "elementStride": 4}
-// CHECK:"name": "tex",
+// METAL:"name": "pdata",
+// METAL:"binding": {"kind": "uniform", "offset": 0, "size": 16, "elementStride": 4}
+// METAL:"name": "tex",
// Since we will apply MetalArgumentBufferTier2, 'tex' here will just be a uniform.
// The pdata is a nested parameter block, so it will be a 64-bit device pointer which take
// 8 bytes. So the offset of `tex` will be 8 bytes.
-// CHECK:"binding": {"kind": "uniform", "offset": 8, "size": 8, "elementStride": 0}
+// METAL:"binding": {"kind": "uniform", "offset": 8, "size": 8, "elementStride": 0}
// Check that there will be only two bindings.
//
-// CHECK: "name": "output",
-// CHECK: "binding": {"kind": "constantBuffer", "index": 1},
+// METAL: "name": "output",
+// METAL: "binding": {"kind": "constantBuffer", "index": 1},
//
+
+//TEST_INPUT: set gParams = new Params{new Data{{0,0,0}}, Texture2D(size=4, content=one)}
struct Data { int3 content; }
struct Params
{
@@ -27,9 +30,13 @@ struct Params
Texture2D tex;
}
ParameterBlock<Params> gParams;
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=output
RWStructuredBuffer<float4> output;
+
[numthreads(1,1,1)]
void computeMain()
{
+ // BUF-COUNT-4: 1.000000
output[0] = gParams.tex.Load(gParams.pdata.content);
}
diff --git a/tests/metal/out-param.slang b/tests/metal/out-param.slang
index f9e89165a..e488f8844 100644
--- a/tests/metal/out-param.slang
+++ b/tests/metal/out-param.slang
@@ -1,5 +1,7 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METAL): -target metal
//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
// Test that we can specailize mutable parameters based on the argument
// address space when generating code for Metal.
@@ -7,13 +9,13 @@
//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;
-// CHECK: void Test_out_param{{.*}}(int thread* value{{.*}})
-// CHECK: void Test_out_param{{.*}}(int device* value{{.*}})
-// CHECK: void Test_out_param{{.*}}(int threadgroup* value{{.*}})
+// METAL: void Test_out_param{{.*}}(int thread* value{{.*}})
+// METAL: void Test_out_param{{.*}}(int device* value{{.*}})
+// METAL: void Test_out_param{{.*}}(int threadgroup* value{{.*}})
-// CHECK: void Test_out_param_wrapper{{.*}}(int thread* value{{.*}})
-// CHECK: void Test_out_param_wrapper{{.*}}(int device* value{{.*}})
-// CHECK: void Test_out_param_wrapper{{.*}}(int threadgroup* value{{.*}})
+// METAL: void Test_out_param_wrapper{{.*}}(int thread* value{{.*}})
+// METAL: void Test_out_param_wrapper{{.*}}(int device* value{{.*}})
+// METAL: void Test_out_param_wrapper{{.*}}(int threadgroup* value{{.*}})
void Test_out_param(out int value)
{
@@ -41,4 +43,7 @@ void computeMain()
outputBuffer[2] = sharedValue[0];
outputBuffer[0]++;
-} \ No newline at end of file
+ // BUF: 2
+ // BUF: 1
+ // BUF: 1
+}
diff --git a/tests/metal/pointer-literals.slang b/tests/metal/pointer-literals.slang
index 327d488d2..4752cf1d7 100644
--- a/tests/metal/pointer-literals.slang
+++ b/tests/metal/pointer-literals.slang
@@ -1,5 +1,7 @@
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -emit-spirv-directly -compute -output-using-type
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;
@@ -17,6 +19,7 @@ void computeMain()
// Test 1: Basic pointer literal assignment
void* ptr1 = nullptr;
outputBuffer[0] = (ptr1 == nullptr) ? 1 : 0;
+ // BUF: 1
// Test 2: Pointer literal in struct
struct TestStruct
@@ -27,4 +30,5 @@ void computeMain()
TestStruct test = { nullptr, 42 };
outputBuffer[1] = (test.ptr == nullptr) ? 1 : 0;
-} \ No newline at end of file
+ // BUF: 1
+}
diff --git a/tests/metal/simple-compute.slang b/tests/metal/simple-compute.slang
index c2ff16685..aa4d36653 100644
--- a/tests/metal/simple-compute.slang
+++ b/tests/metal/simple-compute.slang
@@ -1,7 +1,10 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
-//TEST:REFLECTION(filecheck=REFLECT):-target metal -entry main_kernel -stage compute
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST:REFLECTION(filecheck=REFLECT):-target metal -entry computeMain -stage compute
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type
+//TEST_INPUT:ubuffer(data=[0 0 0], stride=1):out,name=outputBuffer
uniform RWStructuredBuffer<float> outputBuffer;
struct MyBlock
@@ -9,12 +12,14 @@ struct MyBlock
StructuredBuffer<float> b1;
StructuredBuffer<float> b2;
}
+//TEST_INPUT: set block = new MyBlock{ ubuffer(data=[7.0]), ubuffer(data=[0.0]) }
ParameterBlock<MyBlock> block;
+//TEST_INPUT: set block2 = new MyBlock{ ubuffer(data=[0.0]), ubuffer(data=[5.0]) }
ParameterBlock<MyBlock> block2;
-// CHECK: {{\[\[}}kernel{{\]\]}} void main_kernel(float device* {{.*}} {{\[\[}}buffer(0){{\]\]}}, MyBlock{{.*}} constant* block{{.*}} {{\[\[}}buffer(1){{\]\]}}, MyBlock{{.*}} constant* block2{{.*}} {{\[\[}}buffer(2){{\]\]}})
+// METAL: {{\[\[}}kernel{{\]\]}} void computeMain(float device* {{.*}} {{\[\[}}buffer(0){{\]\]}}, MyBlock{{.*}} constant* block{{.*}} {{\[\[}}buffer(1){{\]\]}}, MyBlock{{.*}} constant* block2{{.*}} {{\[\[}}buffer(2){{\]\]}})
-// CHECK-ASM: define void @main_kernel
+// METALLIB: define void @computeMain
// REFLECT: "elementVarLayout": {
// REFLECT: "name": "b1",
@@ -33,13 +38,16 @@ ParameterBlock<MyBlock> block2;
void func(float v)
{
+ // BUF: 3.0
outputBuffer[0] = v;
+ // BUF: 3.0
outputBuffer[1] = outputBuffer.Load(0);
+ // BUF: 12.0
outputBuffer[2] = block.b1[0] + block2.b2[0];
}
[numthreads(1,1,1)]
-void main_kernel()
+void computeMain()
{
func(3.0f);
}
diff --git a/tests/metal/simple-mesh.slang b/tests/metal/simple-mesh.slang
index dc213620b..dc149f71f 100644
--- a/tests/metal/simple-mesh.slang
+++ b/tests/metal/simple-mesh.slang
@@ -1,4 +1,8 @@
//TEST:SIMPLE(filecheck=METAL): -entry meshMain -stage mesh -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -entry meshMain -stage mesh -target metallib
+
+// METALLIB-NOT: error :
+// METALLIB: @meshMain
//
// Mesh shader
@@ -39,6 +43,7 @@ const static uint MAX_VERTS = 12;
const static uint MAX_PRIMS = 4;
[outputtopology("triangle")]
+[shader("mesh")]
[numthreads(12, 1, 1)]
void meshMain(
in uint tig: SV_GroupIndex,
diff --git a/tests/metal/simple-task.slang b/tests/metal/simple-task.slang
index 9d519deb6..1a9da6738 100644
--- a/tests/metal/simple-task.slang
+++ b/tests/metal/simple-task.slang
@@ -1,4 +1,8 @@
//TEST:SIMPLE(filecheck=METAL): -entry taskMain -stage amplification -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -entry taskMain -stage amplification -target metallib
+
+// METALLIB-NOT: error :
+// METALLIB: @taskMain
cbuffer Uniforms
{
diff --git a/tests/metal/stage-in-2.slang b/tests/metal/stage-in-2.slang
index 6ee3b8c51..63fffe869 100644
--- a/tests/metal/stage-in-2.slang
+++ b/tests/metal/stage-in-2.slang
@@ -1,10 +1,10 @@
//TEST:SIMPLE(filecheck=METAL): -target metal
-//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
-// METAL_ASM: define {{.*}} @vertexMain
-// METAL_ASM: define {{.*}} @fragmentMain
+// METALLIB: define {{.*}} @vertexMain
+// METALLIB: define {{.*}} @fragmentMain
// Check that we don't flatten stage-input parameters that have user semantics.
diff --git a/tests/metal/stage-in.slang b/tests/metal/stage-in.slang
index 9a50d163b..bd47d13f1 100644
--- a/tests/metal/stage-in.slang
+++ b/tests/metal/stage-in.slang
@@ -1,46 +1,46 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
-// CHECK: struct [[pixelOutput:pixelOutput_[0-9]+]]
-// CHECK-NEXT:{
-// CHECK-NEXT: float4 output{{.*}}{{\[\[}}color(0){{\]\]}};
-// CHECK-NEXT:};
+// METAL: struct [[pixelOutput:pixelOutput_[0-9]+]]
+// METAL-NEXT:{
+// METAL-NEXT: float4 output{{.*}}{{\[\[}}color(0){{\]\]}};
+// METAL-NEXT:};
-// CHECK: struct pixelInput{{.*}}
-// CHECK-NEXT:{
-// CHECK-NEXT: float4 vertexColor{{.*}} {{\[\[}}user(_SLANG_ATTR){{\]\]}};
-// CHECK-NEXT: float2 vertexUV{{.*}} {{\[\[}}user(_SLANG_ATTR_1){{\]\]}};
-// CHECK-NEXT: float3 vertexNormal{{.*}} {{\[\[}}user(NORMAL){{\]\]}};
-// CHECK-NEXT:};
+// METAL: struct pixelInput{{.*}}
+// METAL-NEXT:{
+// METAL-NEXT: float4 vertexColor{{.*}} {{\[\[}}user(_SLANG_ATTR){{\]\]}};
+// METAL-NEXT: float2 vertexUV{{.*}} {{\[\[}}user(_SLANG_ATTR_1){{\]\]}};
+// METAL-NEXT: float3 vertexNormal{{.*}} {{\[\[}}user(NORMAL){{\]\]}};
+// METAL-NEXT:};
-// CHECK: {{\[\[}}fragment{{\]\]}} [[pixelOutput]] main_fragment(pixelInput{{.*}} {{\[\[}}stage_in{{\]\]}}, float4 position{{.*}} {{\[\[}}position{{\]\]}})
+// METAL: {{\[\[}}fragment{{\]\]}} [[pixelOutput]] main_fragment(pixelInput{{.*}} {{\[\[}}stage_in{{\]\]}}, float4 position{{.*}} {{\[\[}}position{{\]\]}})
-// CHECK: struct FragOut{{.*}}
-// CHECK-NEXT:{
-// CHECK-NEXT: float4 color{{.*}}{{\[\[}}color(0){{\]\]}};
-// CHECK-NEXT: float depth{{.*}} {{\[\[}}depth(any){{\]\]}};
-// CHECK-NEXT:};
+// METAL: struct FragOut{{.*}}
+// METAL-NEXT:{
+// METAL-NEXT: float4 color{{.*}}{{\[\[}}color(0){{\]\]}};
+// METAL-NEXT: float depth{{.*}} {{\[\[}}depth(any){{\]\]}};
+// METAL-NEXT:};
-// CHECK: struct [[vertexOutput:main_vertex_Result_[0-9]+]]
-// CHECK-NEXT:{
-// CHECK-NEXT: float4 position{{.*}} {{\[\[}}position{{\]\]}};
-// CHECK-NEXT: float4 vertexColor{{.*}} {{\[\[}}user(_SLANG_ATTR){{\]\]}};
-// CHECK-NEXT: float2 vertexUV{{.*}} {{\[\[}}user(_SLANG_ATTR_1){{\]\]}};
-// CHECK-NEXT: float3 vertexNormal{{.*}} {{\[\[}}user(NORMAL){{\]\]}};
-// CHECK-NEXT:};
+// METAL: struct [[vertexOutput:main_vertex_Result_[0-9]+]]
+// METAL-NEXT:{
+// METAL-NEXT: float4 position{{.*}} {{\[\[}}position{{\]\]}};
+// METAL-NEXT: float4 vertexColor{{.*}} {{\[\[}}user(_SLANG_ATTR){{\]\]}};
+// METAL-NEXT: float2 vertexUV{{.*}} {{\[\[}}user(_SLANG_ATTR_1){{\]\]}};
+// METAL-NEXT: float3 vertexNormal{{.*}} {{\[\[}}user(NORMAL){{\]\]}};
+// METAL-NEXT:};
-// CHECK: struct vertexInput{{.*}}
-// CHECK-NEXT:{
-// CHECK-NEXT: float4 position{{.*}} {{\[\[}}attribute(0){{\]\]}};
-// CHECK-NEXT: float4 color{{.*}} {{\[\[}}attribute(1){{\]\]}};
-// CHECK-NEXT:};
+// METAL: struct vertexInput{{.*}}
+// METAL-NEXT:{
+// METAL-NEXT: float4 position{{.*}} {{\[\[}}attribute(0){{\]\]}};
+// METAL-NEXT: float4 color{{.*}} {{\[\[}}attribute(1){{\]\]}};
+// METAL-NEXT:};
-// CHECK: {{\[\[}}vertex{{\]\]}} [[vertexOutput]] main_vertex(vertexInput{{.*}}{{\[\[}}stage_in{{\]\]}}, uint vid{{.*}}{{\[\[}}vertex_id{{\]\]}}, uint instanceID{{.*}} {{\[\[}}instance_id{{\]\]}})
+// METAL: {{\[\[}}vertex{{\]\]}} [[vertexOutput]] main_vertex(vertexInput{{.*}}{{\[\[}}stage_in{{\]\]}}, uint vid{{.*}}{{\[\[}}vertex_id{{\]\]}}, uint instanceID{{.*}} {{\[\[}}instance_id{{\]\]}})
-// CHECK-ASM: define {{.*}} @main_vertex
-// CHECK-ASM: define {{.*}} @main_fragment
-// CHECK-ASM: define {{.*}} @main_fragment1
+// METALLIB: define {{.*}} @main_vertex
+// METALLIB: define {{.*}} @main_fragment
+// METALLIB: define {{.*}} @main_fragment1
struct VIn
{
diff --git a/tests/metal/sv_target-complex-1.slang b/tests/metal/sv_target-complex-1.slang
index ed145093b..15a75f616 100644
--- a/tests/metal/sv_target-complex-1.slang
+++ b/tests/metal/sv_target-complex-1.slang
@@ -1,5 +1,5 @@
//TEST:SIMPLE(filecheck=METAL): -target metal
-//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
@@ -22,7 +22,7 @@ struct Output
NestedReturn2 debug2 : SV_TaRget3;
}
-// METAL_ASM: define {{.*}} @fragmentMain
+// METALLIB: define {{.*}} @fragmentMain
// METAL: color(0)
// METAL-DAG: color(1)
// METAL-DAG: color(2)
diff --git a/tests/metal/sv_target-complex-2.slang b/tests/metal/sv_target-complex-2.slang
index 70ee4002e..f78737730 100644
--- a/tests/metal/sv_target-complex-2.slang
+++ b/tests/metal/sv_target-complex-2.slang
@@ -1,5 +1,5 @@
//TEST:SIMPLE(filecheck=METAL): -target metal
-//TEST:SIMPLE(filecheck=METAL_ASM): -target metallib
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
//TEST:SIMPLE(filecheck=WGSL): -target wgsl
//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm
@@ -16,7 +16,7 @@ struct Output
float4 Material : SV_Target2;
}
-// METAL_ASM: define {{.*}} @fragmentMain
+// METALLIB: define {{.*}} @fragmentMain
// METAL: color(0)
// METAL: color(1)
// METAL-DAG: color(3)
diff --git a/tests/metal/sv_target.slang b/tests/metal/sv_target.slang
index 4c7c6e8da..edbf3ef07 100644
--- a/tests/metal/sv_target.slang
+++ b/tests/metal/sv_target.slang
@@ -1,5 +1,5 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
struct Output
{
@@ -8,13 +8,13 @@ struct Output
float4 Material : SV_Target2;
}
-// CHECK-ASM: define {{.*}} @fragMain
-// CHECK: color(0)
-// CHECK: color(1)
-// CHECK: color(2)
+// METALLIB: define {{.*}} @fragMain
+// METAL: color(0)
+// METAL: color(1)
+// METAL: color(2)
[shader("fragment")]
Output fragMain()
{
return { float4(1), float4(2), float4(3) };
-} \ No newline at end of file
+}
diff --git a/tests/metal/system-val-conversion.slang b/tests/metal/system-val-conversion.slang
index dd8e103ae..68f12d859 100644
--- a/tests/metal/system-val-conversion.slang
+++ b/tests/metal/system-val-conversion.slang
@@ -1,29 +1,32 @@
-//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
-//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type
// Test that we always emit correct type for system value and insert conversion logic
// if the declared type of the SV is different from the spec-defined type.
-uniform RWStructuredBuffer<float> outputBuffer;
+//TEST_INPUT: ubuffer(data=[0], stride=1):out,name outputBuffer
+uniform RWStructuredBuffer<uint> outputBuffer;
+//TEST_INPUT: ubuffer(data=[5 0 0 0 0 0 0 0], stride=4, count=32):name buffer
RWByteAddressBuffer buffer;
-// CHECK-ASM: define void @main_kernel
+// METALLIB: define void @computeMain
struct TestStruct
{
uint8_t a;
- float16_t h;
float b;
- float4 c;
- float4x3 d;
}
-// CHECK: void main_kernel(uint3 tid{{.*}}
-// CHECK: uint(int(tid{{.*}}.x))
+// METAL: void computeMain(uint3 tid{{.*}}
+// METAL: uint(int(tid{{.*}}.x))
[numthreads(1,1,1)]
-void main_kernel(int tid: SV_DispatchThreadID)
+void computeMain(int tid: SV_DispatchThreadID)
{
- buffer.Store(128, buffer.Load<TestStruct>(tid));
+ buffer.Store(16, buffer.Load<TestStruct>(tid));
+ // BUF: 5
+ outputBuffer[0] = buffer.Load<TestStruct>(16).a;
}
diff --git a/tests/metal/test_buffer.slang b/tests/metal/test_buffer.slang
index 122af3b9a..78959aa10 100644
--- a/tests/metal/test_buffer.slang
+++ b/tests/metal/test_buffer.slang
@@ -1,13 +1,17 @@
// Test that Buffer<T> maps to texture_buffer<uint, access::read> in Metal
//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib
+// No COMPARE_COMPUTE test; currently the test framework can't setup a Buffer<>
+// TODO: github issue #8456
// METAL: texture_buffer<uint, access::read> inputBuffer_{{.*}}
Buffer<uint> inputBuffer;
RWStructuredBuffer<uint> outputBuffer;
+// METALLIB: @computeMain
[numthreads(4, 1, 1)]
void computeMain(uint3 dtid : SV_DispatchThreadID)
{
diff --git a/tests/metal/test_descriptor_handle.slang b/tests/metal/test_descriptor_handle.slang
index 8579fee4a..1e9072a79 100644
--- a/tests/metal/test_descriptor_handle.slang
+++ b/tests/metal/test_descriptor_handle.slang
@@ -1,10 +1,10 @@
-//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target metal
+//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal
struct MyStruct
{
uint value;
}
-// CHECK-NOT: DescriptorHandle
+// METAL-NOT: DescriptorHandle
ParameterBlock<DescriptorHandle<Buffer<uint>>> param;
RWStructuredBuffer<uint> outputBuffer;
[numthreads(4, 1, 1)]
@@ -12,6 +12,6 @@ void computeMain(uint3 dtid : SV_DispatchThreadID)
{
uint idx = dtid.x;
// Load values from the buffer to verify correct access
- // CHECK: {{.*}}outputBuffer{{.*}}=
+ // METAL: {{.*}}outputBuffer{{.*}}=
outputBuffer[idx] = param[0];
}
diff --git a/tests/metal/texture-multisample.slang b/tests/metal/texture-multisample.slang
index 4bd6e3be0..310c165c1 100644
--- a/tests/metal/texture-multisample.slang
+++ b/tests/metal/texture-multisample.slang
@@ -1,8 +1,13 @@
//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE
+//DISABLE_TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib -DEMIT_SOURCE
+
+// Disabled due to location argument being passed wrong argument type
+// TODO: github issue #8457
+
+// METALLIB-NOT: error :
+// METALLIB: @computeMain
-// TEST_INPUT: RWTexture2D(size=4, content = zero, sampleCount=2):name texMS
Texture2DMS<float4> texMS;
-// TEST_INPUT: RWTexture2D(size=4, content = zero):name output
RWTexture2D<float4> output;
[numthreads(1, 1, 1)]
@@ -13,4 +18,4 @@ void computeMain()
// METAL: {{.*}}access::read{{.*}}
float4 v = texMS.Load(location, sampleIndex);
output[location] = v;
-} \ No newline at end of file
+}
diff --git a/tests/metal/texture-store-vector.slang b/tests/metal/texture-store-vector.slang
index 0f63b7ce3..94c617e92 100644
--- a/tests/metal/texture-store-vector.slang
+++ b/tests/metal/texture-store-vector.slang
@@ -1,4 +1,8 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METAL): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+
+// METALLIB-NOT: error :
+// METALLIB: @computeMain
// Test that we can compile texture store operations with 2-component vectors
// without segfaulting. This reproduces the issue where legalizeImageStoreValue
@@ -11,6 +15,6 @@ RWTexture2D<float2> output;
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
// This should expand float2(1,2) to float4(1,2,0,0)
- // CHECK: {{.*}}float4(1.0, 2.0,
+ // METAL: {{.*}}float4(1.0, 2.0,
output.Store(dispatchThreadID.xy, float2(1, 2));
-} \ No newline at end of file
+}
diff --git a/tests/metal/texture-write.slang b/tests/metal/texture-write.slang
index 7967e1d16..48f5dfa6b 100644
--- a/tests/metal/texture-write.slang
+++ b/tests/metal/texture-write.slang
@@ -1,26 +1,32 @@
-//TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE
-//TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib
+//DISABLE_TEST:SIMPLE(filecheck=METAL): -stage compute -entry computeMain -target metal -DEMIT_SOURCE
+//DISABLE_TEST:SIMPLE(filecheck=METALLIB): -stage compute -entry computeMain -target metallib
+//DISABLE_TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type
+
+// Test framework has issues with RWTexture2D on Metal
+// TODO: github issue #8454
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float4> outputBuffer;
+
// for some reason, metal textures dont have an overload for less-than-four component
// writes, they need to be converted to 4-components in a legalize step, as the other components
// get discarded
+
+//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero):name pWrites.tex1
+//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero):name pWrites.tex2
+//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero):name pWrites.tex4
+//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content=zero, arrayLength=2):name pWrites.tex1Array
+//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content=zero, arrayLength=2):name pWrites.tex2Array
+//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content=zero, arrayLength=2):name pWrites.tex4Array
struct TextureWrite
{
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32
RWTexture2D<float> tex1;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v2
RWTexture2D<float2> tex2;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v3
- RWTexture2D<float3> tex3;
- //TEST_INPUT: RWTexture2D(size=4, content = zero):name t2D_f32v4
RWTexture2D<float4> tex4;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32
RWTexture2DArray<float> tex1Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v2
RWTexture2DArray<float2> tex2Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v3
- RWTexture2DArray<float3> tex3Array;
- //TEST_INPUT: RWTexture2DArray(size=4, content = zero):name t2D_f32v4
RWTexture2DArray<float4> tex4Array;
}
ParameterBlock<TextureWrite> pWrites;
@@ -31,27 +37,34 @@ void computeMain()
// TODO: check for the type of first parameter to be a 4-component vector
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex1[uint2(1, 1)] = 1;
- // METALLIB: call {{.*}}.write_texture_2d.v4f32(
- // METAL: .write(
- pWrites.tex2[uint2(2, 2)] = float2(1, 2);
+ pWrites.tex1[uint2(0, 0)] = float(1);
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex3[uint2(3, 3)] = float3(1, 2, 3);
+ pWrites.tex2[uint2(1, 1)] = float2(1, 2);
// METALLIB: call {{.*}}.write_texture_2d.v4f32(
// METAL: .write(
- pWrites.tex4[uint2(4, 4)] = float4(1, 2, 3, 4);
+ pWrites.tex4[uint2(3, 3)] = float4(1, 2, 3, 4);
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex1Array[uint3(1, 1, 1)] = 1;
- // METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
- // METAL: .write(
- pWrites.tex2Array[uint3(2, 2, 2)] = float2(1, 2);
+ pWrites.tex1Array[uint3(0, 0, 0)] = 1;
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex3Array[uint3(3, 3, 3)] = float3(1, 2, 3);
+ pWrites.tex2Array[uint3(1, 1, 0)] = float2(1, 2);
// METALLIB: call {{.*}}.write_texture_2d_array.v4f32(
// METAL: .write(
- pWrites.tex4Array[uint3(4, 4, 4)] = float4(1, 2, 3, 4);
-} \ No newline at end of file
+ pWrites.tex4Array[uint3(3, 3, 0)] = float4(1, 2, 3, 4);
+
+ // BUF: 6.000000
+ // BUF: 8.000000
+ // BUF: 6.000000
+ // BUF: 8.000000
+ outputBuffer[0] = float4(0)
+ + float4(pWrites.tex1[uint2(0, 0)], 0, 0, 0)
+ + float4(pWrites.tex2[uint2(1, 1)], 0, 0)
+ + float4(pWrites.tex4[uint2(3, 3)])
+ + float4(pWrites.tex1Array[uint3(0, 0, 0)], 0, 0, 0)
+ + float4(pWrites.tex2Array[uint3(1, 1, 0)], 0, 0)
+ + float4(pWrites.tex4Array[uint3(3, 3, 0)])
+ ;
+}
diff --git a/tests/metal/texture.slang b/tests/metal/texture.slang
index 7673298e9..c495bb3b3 100644
--- a/tests/metal/texture.slang
+++ b/tests/metal/texture.slang
@@ -5,6 +5,10 @@
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=FUNCTIONAL):-slang -compute -dx12 -profile cs_6_6 -shaderobj -output-using-type -xslang -DEXCLUDE_INTEGER_TYPE -xslang -DEXCLUDE_SM_6_7
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=FUNCTIONAL):-vk -emit-spirv-directly -compute -shaderobj -output-using-type -render-feature hardware-device -xslang -DEXCLUDE_HALF_TYPE -xslang -DEXCLUDE_SHORT_TYPE
+//DISABLE_TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=FUNCTIONAL):-metal -compute -shaderobj -output-using-type
+
+// Internal compiler error on metal
+// TODO: github issue #8486
//TEST_INPUT: ubuffer(data=[0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;
diff --git a/tests/metal/thread_position_in_threadgroup.slang b/tests/metal/thread_position_in_threadgroup.slang
index a20fe2ec7..c8494c4ed 100644
--- a/tests/metal/thread_position_in_threadgroup.slang
+++ b/tests/metal/thread_position_in_threadgroup.slang
@@ -1,12 +1,18 @@
-//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target metal -D GROUPID
-//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target metal
+//TEST:SIMPLE(filecheck=METAL): -entry computeMain -stage compute -target metal -D GROUPID
+//TEST:SIMPLE(filecheck=METAL): -entry computeMain -stage compute -target metal
+//DISABLE_TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
+//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type
-//CHECK: computeMain
+// Compute test disabled; Buffer isn't handled by the test infrastructure
+// TODO: github issue #8456
+
+//METAL: computeMain
// ensure we compute the SV_GroupIndex from SV_GroupThreadID and `numthreads`
-// CHECK: thread_position_in_threadgroup
-// CHECK-DAG: *{{.*}}2
+// METAL: thread_position_in_threadgroup
+// METAL-DAG: *{{.*}}2
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name dst
RWBuffer<uint> dst;
void indirection(uint groupIndex)
@@ -22,6 +28,10 @@ void computeMain(uint GI : SV_GroupIndex, uint GTID : SV_GroupThreadID)
void computeMain(uint GI : SV_GroupIndex)
#endif
{
+ // BUF: 0
+ // BUF: 1
dst[GI + THREAD_COUNT] = GI;
+ // BUF: 0
+ // BUF: 1
indirection(GI);
-} \ No newline at end of file
+}
diff --git a/tests/metal/vector-argument-buffer-layout.slang b/tests/metal/vector-argument-buffer-layout.slang
index 5e45e3a01..dcc89be7c 100644
--- a/tests/metal/vector-argument-buffer-layout.slang
+++ b/tests/metal/vector-argument-buffer-layout.slang
@@ -1,17 +1,19 @@
-//TEST:REFLECTION(filecheck=CHECK): -target metal
+//TEST:REFLECTION(filecheck=METAL): -target metal
+//TEST(compute, metal):COMPARE_COMPUTE(filecheck-buffer=BUF):-metal -compute -entry computeMain -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -output-using-type
-//CHECK: "name": "o",
-//CHECK: "binding": {"kind": "constantBuffer", "index": 0},
+//METAL: "name": "o",
+//METAL: "binding": {"kind": "constantBuffer", "index": 0},
-//CHECK: "name": "gParams",
-//CHECK: "binding": {"kind": "constantBuffer", "index": 1},
+//METAL: "name": "gParams",
+//METAL: "binding": {"kind": "constantBuffer", "index": 1},
-//CHECK: "dir"
-//CHECK: "binding": {"kind": "uniform", "offset": 0, "size": 16, "elementStride": 4}
-//CHECK: "color"
-//CHECK: "binding": {"kind": "uniform", "offset": 16, "size": 16, "elementStride": 4}
+//METAL: "dir"
+//METAL: "binding": {"kind": "uniform", "offset": 0, "size": 16, "elementStride": 4}
+//METAL: "color"
+//METAL: "binding": {"kind": "uniform", "offset": 16, "size": 16, "elementStride": 4}
struct Params
{
@@ -19,11 +21,14 @@ struct Params
float4 color;
}
+//TEST_INPUT: ubuffer(data=[0.0], stride=4):out,name o
RWStructuredBuffer<float> o;
+//TEST_INPUT: set gParams = new Params{{3.0, 4.0, 5.0}, {6.0, 7.0 ,8.0, 9.0}}
ParameterBlock<Params> gParams;
[numthreads(1,1,1)]
void computeMain()
{
+ // BUF: 3.0
o[0] = gParams.dir.x;
}
diff --git a/tests/metal/vector-get-element-ptr.slang b/tests/metal/vector-get-element-ptr.slang
index 1c616b37e..ad2426214 100644
--- a/tests/metal/vector-get-element-ptr.slang
+++ b/tests/metal/vector-get-element-ptr.slang
@@ -1,6 +1,7 @@
-//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METAL): -target metal
//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -mtl
+//TEST(smoke,compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -vk
//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
@@ -14,9 +15,9 @@ void modify(inout int v)
void computeMain(int3 v : SV_DispatchThreadID)
{
int3 u = v;
- // CHECK: int [[TEMP:[a-zA-Z0-9_]+]] = [[OUT:[a-zA-Z0-9_]+]].x;
- // CHECK: modify{{.*}}(&[[TEMP]])
- // CHECK: [[OUT]].x = [[TEMP]];
+ // METAL: int [[TEMP:[a-zA-Z0-9_]+]] = [[OUT:[a-zA-Z0-9_]+]].x;
+ // METAL: modify{{.*}}(&[[TEMP]])
+ // METAL: [[OUT]].x = [[TEMP]];
modify(u.x);
// BUF: 2
diff --git a/tests/pipeline/rasterization/mesh/dead-loop.slang b/tests/pipeline/rasterization/mesh/dead-loop.slang
index 8277ad2c2..47435e835 100644
--- a/tests/pipeline/rasterization/mesh/dead-loop.slang
+++ b/tests/pipeline/rasterization/mesh/dead-loop.slang
@@ -1,5 +1,6 @@
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -dx12 -profile sm_6_6 -render-features mesh-shader
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile sm_6_5 -render-features mesh-shader
+//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -metal -render-features mesh-shader
// See https://github.com/shader-slang/slang/issues/3401