summaryrefslogtreecommitdiffstats
path: root/tests/bindings
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-07-30 20:28:34 -0700
committerGitHub <noreply@github.com>2024-07-30 20:28:34 -0700
commit6e4b82741893be55f6216c31e19650029c667078 (patch)
treefefd4529c6066763653732d7f93ca5cf07027a76 /tests/bindings
parent04e7327a2067c82db3eaef51955f211e148ac933 (diff)
Fixes for Metal ParameterBlock support. (#4752)
Diffstat (limited to 'tests/bindings')
-rw-r--r--tests/bindings/nested-parameter-block-3.slang53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/bindings/nested-parameter-block-3.slang b/tests/bindings/nested-parameter-block-3.slang
new file mode 100644
index 000000000..a9cfcfdaa
--- /dev/null
+++ b/tests/bindings/nested-parameter-block-3.slang
@@ -0,0 +1,53 @@
+// nested-parameter-block-3.slang
+//
+// Same as nest-parameter-block-2, the only difference is that we added member methods
+// to ParameterBlock element types to exercise the legalization logic of method calls.
+
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 -use-dxil -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal -shaderobj -output-using-type -render-features argument-buffer-tier-2
+
+
+struct CB
+{
+ uint4 value;
+}
+
+struct MaterialSystem
+{
+ CB cb;
+ RWStructuredBuffer<uint4> data;
+ uint4 readData() { return data[0]; }
+}
+
+struct Scene
+{
+ CB sceneCb;
+ RWStructuredBuffer<uint4> data;
+ ParameterBlock<MaterialSystem> material;
+ uint4 readMaterialData() { return material.readData(); }
+}
+
+//TEST_INPUT: set scene = new Scene { { {1,2,3,4} }, ubuffer(data=[1 2 3 4], stride=4), new MaterialSystem {{ {1,2,3,4} }, ubuffer(data=[1 2 3 4], stride=4)} }
+ParameterBlock<Scene> scene;
+
+struct MyBuffer
+{
+ RWStructuredBuffer<uint> resultBuffer;
+}
+//TEST_INPUT: set pb2 = new MyBuffer { out ubuffer(data=[0 0 0 0], stride=4) }
+ParameterBlock<MyBuffer> pb2;
+
+// Main entry-point. Applies the transformation encoded by `transformer`
+// to all elements in `buffer`.
+[shader("compute")]
+[numthreads(1,1,1)]
+void computeMain(uint3 sv_dispatchThreadID : SV_DispatchThreadID)
+{
+ // CHECK: type: uint32_t
+ // CHECK-NEXT: 4
+ // CHECK-NEXT: 2
+ pb2.resultBuffer[0] = scene.sceneCb.value.x + scene.data[0].x + scene.material.cb.value.x + scene.material.data[0].x;
+ pb2.resultBuffer[1] = scene.readMaterialData().y;
+}