Hello -
I am seeking clarification on the description of the additional capabilities for argument buffers on Tier 2 hardware described in Section 2.12.1 of MSL Specification v. 2.3.
The specification states: "You can access argument buffers through pointer indexing. This syntax shown below refers to an array of consecutive, independently encoded argument buffers:" Then proceeds to provide an example.
I am able to replicate this behavior on an iPad Pro that supports only Tier 1 argument buffers in a kernel function. The argument buffer is simple and along the lines of the following:
Where arguments is a metal buffer with a size equal to the length of the argument encoder multiplied by the number of elements to be accessed via pointer indexing (i.e., in the pseudo case above the size is encoded length times two).
MSL goes on to say that Tier 2 argument buffers can have pointers to other argument buffers. In experimenting, I was also able to replicate this behavior on Tier 1 hardware. The method newArgumentEncoderForBufferAtIndex: always returns nil, but if I instead create the argument encoder with an array of MTLArgumentDescriptor objects, I can encode that buffer in the same manner as described above and nest it into another argument buffer.
I expected Metal to throw an error based on the MSL section cited above. Is this undefined behavior that just happens not to crash on this device or am I not understanding what MSL is trying to say?
Of note, Metal does throw an error if I try to do this in a vertex or fragment function.
I am seeking clarification on the description of the additional capabilities for argument buffers on Tier 2 hardware described in Section 2.12.1 of MSL Specification v. 2.3.
The specification states: "You can access argument buffers through pointer indexing. This syntax shown below refers to an array of consecutive, independently encoded argument buffers:" Then proceeds to provide an example.
I am able to replicate this behavior on an iPad Pro that supports only Tier 1 argument buffers in a kernel function. The argument buffer is simple and along the lines of the following:
Code Block Metal typedef struct MyAB { constant float * buffer [[ id(0) ]]; texture2d<float> texture [[ id(1) ]]; } MyAB; void kernel (const device MyAB * arguments [[ buffer(0) ]] { MyAB argument1 = arguments[0]; MyAB argument2 = arguments[1]; / etc / }
Where arguments is a metal buffer with a size equal to the length of the argument encoder multiplied by the number of elements to be accessed via pointer indexing (i.e., in the pseudo case above the size is encoded length times two).
MSL goes on to say that Tier 2 argument buffers can have pointers to other argument buffers. In experimenting, I was also able to replicate this behavior on Tier 1 hardware. The method newArgumentEncoderForBufferAtIndex: always returns nil, but if I instead create the argument encoder with an array of MTLArgumentDescriptor objects, I can encode that buffer in the same manner as described above and nest it into another argument buffer.
I expected Metal to throw an error based on the MSL section cited above. Is this undefined behavior that just happens not to crash on this device or am I not understanding what MSL is trying to say?
Of note, Metal does throw an error if I try to do this in a vertex or fragment function.