summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-13 16:29:58 -0700
committerGitHub <noreply@github.com>2024-06-13 16:29:58 -0700
commitcfef0c6f66c9d36ae2899c8c2790c3fe422a7700 (patch)
tree0e116769009ae7e4b3b16d2ef28f275bea5e1fd7 /tests/compute
parent2407966e899f9e4f490b23a92fc06d5da20544cc (diff)
Metal: misc fixes and enable more tests. (#4374)
* Fix and enable tests for metal. * Fix. * Fix. * Fix tests. * Fix warnings. * Fix. --------- Co-authored-by: Yong He <yonghe@Yongs-Mac-mini.local>
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/byte-address-buffer.slang1
-rw-r--r--tests/compute/cbuffer-legalize.slang1
-rw-r--r--tests/compute/frem.slang1
-rw-r--r--tests/compute/matrix-layout-structured-buffer.slang1
-rw-r--r--tests/compute/non-square-column-major.slang8
-rw-r--r--tests/compute/non-square-row-major.slang19
-rw-r--r--tests/compute/non-square-row-major.slang.expected.txt3
-rw-r--r--tests/compute/structured-buffer-of-matrices.slang2
-rw-r--r--tests/compute/texture-simple.slang1
9 files changed, 21 insertions, 16 deletions
diff --git a/tests/compute/byte-address-buffer.slang b/tests/compute/byte-address-buffer.slang
index 80a1e8e16..65356ec22 100644
--- a/tests/compute/byte-address-buffer.slang
+++ b/tests/compute/byte-address-buffer.slang
@@ -4,7 +4,6 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
// Confirm cross-compilation of `(RW)ByteAddressBuffer`
//
diff --git a/tests/compute/cbuffer-legalize.slang b/tests/compute/cbuffer-legalize.slang
index 5da305eab..d0c0a8777 100644
--- a/tests/compute/cbuffer-legalize.slang
+++ b/tests/compute/cbuffer-legalize.slang
@@ -1,6 +1,5 @@
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE:-shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
//TEST_INPUT: uniform(data=[1 2 3 4]):name=C.p.c
//TEST_INPUT: Texture2D(size=4, content = one):name=C.p.t
diff --git a/tests/compute/frem.slang b/tests/compute/frem.slang
index 8d6551e79..893f29794 100644
--- a/tests/compute/frem.slang
+++ b/tests/compute/frem.slang
@@ -3,7 +3,6 @@
//TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj -emit-spirv-directly -output-using-type
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
// Test uses of floating-point `%` operator.
diff --git a/tests/compute/matrix-layout-structured-buffer.slang b/tests/compute/matrix-layout-structured-buffer.slang
index 588c93685..8ef7077f8 100644
--- a/tests/compute/matrix-layout-structured-buffer.slang
+++ b/tests/compute/matrix-layout-structured-buffer.slang
@@ -10,6 +10,7 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-row-major -shaderobj -dx12
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-column-major -shaderobj -dx12
+
//TEST_INPUT:ubuffer(data=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23], stride=48):name=gMatrices
RWStructuredBuffer<int3x4> gMatrices;
diff --git a/tests/compute/non-square-column-major.slang b/tests/compute/non-square-column-major.slang
index 09ed8e1c2..fd3ce6406 100644
--- a/tests/compute/non-square-column-major.slang
+++ b/tests/compute/non-square-column-major.slang
@@ -8,7 +8,7 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -xslang -matrix-layout-column-major -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -xslang -matrix-layout-column-major -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -xslang -matrix-layout-column-major -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=METAL):-slang -output-using-type -shaderobj -mtl
// matrix<R, C>
//TEST_INPUT:cbuffer(data=[1.0 0.0 10.0 0.0 0.0 1.0 20.0 0.0]):name matrixBuffer
@@ -26,6 +26,12 @@ void computeMain(uint3 tid : SV_DispatchThreadID)
float2 r = mul(v, M);
+ // Metal always uses scalar layout + row major, so it is computing
+ // [1 0]
+ // [ 1 2 1] * [10 0] = [ 21 1 ]
+ // [0 1]
+ // METAL: 21
+ // METAL: 1
output[0] = r.x;
output[1] = r.y;
}
diff --git a/tests/compute/non-square-row-major.slang b/tests/compute/non-square-row-major.slang
index b9a9c2fbb..867231cd3 100644
--- a/tests/compute/non-square-row-major.slang
+++ b/tests/compute/non-square-row-major.slang
@@ -3,16 +3,16 @@
// Note! This test doesn't work on CUDA or CPU targets, because both these targets
// assume matrices are tightly packed, whereas GPU targets align rows to 16 bytes.
-//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -compile-arg -O3 -xslang -matrix-layout-row-major -shaderobj
-//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
-//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -xslang -matrix-layout-row-major -shaderobj
-//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=PACKED):-cpu -compute -output-using-type -compile-arg -O3 -xslang -matrix-layout-row-major -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-slang -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-slang -compute -dx12 -output-using-type -xslang -matrix-layout-row-major -shaderobj
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=ALIGNED):-vk -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=PACKED):-cuda -compute -output-using-type -xslang -matrix-layout-row-major -shaderobj
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=PACKED): -slang -output-using-type -shaderobj -mtl
// matrix<R, C>
-//TEST_INPUT:cbuffer(data=[1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 10.0 20.0 0.0 0.0 ]):name matrixBuffer
+//TEST_INPUT:cbuffer(data=[1.0 2.0 3.0 4.0 5.0 6.0 0.0 0.0 10.0 20.0 0.0 0.0 ]):name matrixBuffer
ConstantBuffer<float3x2> matrixBuffer;
//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name output
@@ -27,6 +27,11 @@ void computeMain(uint3 tid : SV_DispatchThreadID)
float2 r = mul(v, M);
+ // ALIGNED: 21
+ // ALIGNED: 34
+
+ // PACKED: 12
+ // PACKED: 16
output[0] = r.x;
output[1] = r.y;
}
diff --git a/tests/compute/non-square-row-major.slang.expected.txt b/tests/compute/non-square-row-major.slang.expected.txt
deleted file mode 100644
index df7317d53..000000000
--- a/tests/compute/non-square-row-major.slang.expected.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-type: float
-11.000000
-22.000000
diff --git a/tests/compute/structured-buffer-of-matrices.slang b/tests/compute/structured-buffer-of-matrices.slang
index 507611d5a..f2afd4fae 100644
--- a/tests/compute/structured-buffer-of-matrices.slang
+++ b/tests/compute/structured-buffer-of-matrices.slang
@@ -15,7 +15,7 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-row-major -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -xslang -matrix-layout-row-major -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -matrix-layout-row-major -shaderobj
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
+
// Note: we are using a buffer of floating-point matrices, but fill it with integer
// data, to allow this test to work on the Vulkan targets, which do not currently
diff --git a/tests/compute/texture-simple.slang b/tests/compute/texture-simple.slang
index b06be9a49..efa83edfb 100644
--- a/tests/compute/texture-simple.slang
+++ b/tests/compute/texture-simple.slang
@@ -4,7 +4,6 @@
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -use-dxil -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type -render-feature hardware-device
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
-//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
// Doesn't work on CUDA, not clear why yet
//DISABLE_TEST_INPUT: Texture1D(format=R_Float32, size=4, content = one, mipMaps=1):name tLoad1D