Skip to content

Motivation

MaximV88 edited this page Apr 15, 2020 · 1 revision

Metal's Reflection Utility

Metal framework comes with a little known feature that provides type data about what input do metal functions expect. This seems trivial since the developer, who has access to .metal source code, can easily come up with a 'native' argument binding solution without needing much assistance.

But it's not that simple. Without knowing the unwritten rules of Metal binding it is difficult to handle a case like:

struct ArgumentBufferWithArgumentBufferAndArray {
    constant ArgumentBuffer *i;
    int i_array[10];
    metal::array<uint, 10> ui_array;
};

kernel void my_function(device metal::array<ArgumentBufferWithArgumentBufferAndArray, 10> & argument_buffer)
{
    ...
}

How do you bind an argument buffer to an argument buffer array?
How do you set a value in a metal array on an argument buffer in an argument buffer array?
How do you calculate index strides?

Luckily Metal provides this type of information.
Aluminum uses the Type information to create a Switfty interface that tackles difficult tasks.

Clone this wiki locally