summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/slang-type-layout.cpp13
-rw-r--r--tests/metal/vector-argument-buffer-layout.slang18
2 files changed, 31 insertions, 0 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index c6acf5250..98a324d96 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -1898,6 +1898,19 @@ struct MetalArgumentBufferElementLayoutRulesImpl : ObjectLayoutRulesImpl, Defaul
return SimpleLayoutInfo(LayoutResourceKind::MetalArgumentBufferElement, 1);
}
+ SimpleLayoutInfo GetVectorLayout(
+ BaseType elementType,
+ SimpleLayoutInfo elementInfo,
+ size_t elementCount) override
+ {
+ SLANG_UNUSED(elementType);
+ SLANG_UNUSED(elementInfo);
+ SLANG_UNUSED(elementCount);
+
+ // A vector occupies one [[id]] slot in a metal argument buffer.
+ return SimpleLayoutInfo(LayoutResourceKind::MetalArgumentBufferElement, 1);
+ }
+
virtual ObjectLayoutInfo GetObjectLayout(ShaderParameterKind kind, const Options& /* options */)
override
{
diff --git a/tests/metal/vector-argument-buffer-layout.slang b/tests/metal/vector-argument-buffer-layout.slang
new file mode 100644
index 000000000..698fd30d8
--- /dev/null
+++ b/tests/metal/vector-argument-buffer-layout.slang
@@ -0,0 +1,18 @@
+//TEST:REFLECTION(filecheck=CHECK): -target metal
+//CHECK: "binding": {"kind": "metalArgumentBufferElement", "index": 0}
+//CHECK: "binding": {"kind": "metalArgumentBufferElement", "index": 1}
+
+struct Params
+{
+ float3 dir;
+ float4 color;
+}
+
+RWStructuredBuffer<float> o;
+ParameterBlock<Params> gParams;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ o[0] = gParams.dir.x;
+} \ No newline at end of file