Group Group Group Group Group Group Group Group Group

Tier 1 vs. Tier 2 Argument Buffer Features

Hello -

I am struggling to understand one of the differences between Tier 1 Argument Buffers and Tier 2. Can anyone shed some light?

The [Apple Developer Documentation] says that Tier 2 argument buffers can be accessed through pointer indexing and provides this example:

kernel void my_kernel(constant My_AB_Resources *resourcesArray [[buffer(0)]]) {
constant My_AB_Resources & resources = resourcesArray[3];

In the book, we do something similar:

Model model = modelsArray[modelIndex];

The only difference appears to be the use of the address of operator (&) and the memory address space (constant) in the example from the developer documentation.

I gather that the first code sample is creating an alias to the element at index 3 of the resourcesArray. But why is that significant? Does it have to do with the immutability of Tier 1 argument buffers?

Tier 2 can use arrays of argument buffers, which is what the code above is using. Tier 1 can’t use arrays of argument buffers, just a single one.