summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-24 16:23:35 -0700
committerGitHub <noreply@github.com>2024-04-24 16:23:35 -0700
commitd3ed08ec3073c3cb9ac24fa3670784dd6e97a164 (patch)
tree8589874c7dd2c1698a5dcbe22d7a2bd74fa29abf /tests
parentfc4c242442510fb97c3cfbf04d7582ebbc3bb0ed (diff)
Parameter layout and reflection for Metal bindings. (#4022)
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/simple-compute.slang27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/metal/simple-compute.slang b/tests/metal/simple-compute.slang
index 56d8fefd4..b5c0aaf75 100644
--- a/tests/metal/simple-compute.slang
+++ b/tests/metal/simple-compute.slang
@@ -1,16 +1,41 @@
//TEST:SIMPLE(filecheck=CHECK): -target metal
//TEST:SIMPLE(filecheck=CHECK-ASM): -target metallib
+//TEST:REFLECTION(filecheck=REFLECT):-target metal
uniform RWStructuredBuffer<float> outputBuffer;
-// CHECK: {{.*}}kernel{{.*}} void main_kernel(float device* {{.*}})
+struct MyBlock
+{
+ StructuredBuffer<float> b1;
+ StructuredBuffer<float> b2;
+}
+ParameterBlock<MyBlock> block;
+ParameterBlock<MyBlock> block2;
+
+// CHECK: {{\[\[}}kernel{{\]\]}} void main_kernel(float device* {{.*}} {{\[\[}}buffer(0){{\]\]}}, MyBlock{{.*}} constant* block{{.*}} {{\[\[}}buffer(1){{\]\]}}, MyBlock{{.*}} constant* block2{{.*}} {{\[\[}}buffer(2){{\]\]}})
// CHECK-ASM: define void @main_kernel
+// REFLECT: "elementVarLayout": {
+// REFLECT: "name": "b1",
+// REFLECT: "binding": {"kind": "metalArgumentBufferElement", "index": 0}
+
+// REFLECT: "name": "b2",
+// REFLECT: "binding": {"kind": "metalArgumentBufferElement", "index": 1}
+
+// REFLECT: "binding": {"kind": "metalArgumentBufferElement", "index": 0, "count": 2}
+
+// REFLECT: "name": "outputBuffer",
+// REFLECT-NEXT: "binding": {"kind": "constantBuffer", "index": 0, "used": 0}
+
+// REFLECT: "name": "block",
+// REFLECT-NEXT: "binding": {"kind": "constantBuffer", "index": 1, "used": 0}
+
void func(float v)
{
outputBuffer[0] = v;
outputBuffer[1] = outputBuffer.Load(0);
+ outputBuffer[2] = block.b1[0] + block2.b2[0];
}
[numthreads(1,1,1)]