Contents

setConstantValues(_:type:range:)

Sets values for a group of function constants within a specific index range.

Declaration

func setConstantValues(_ values: UnsafeRawPointer, type: MTLDataType, range: Range<Int>)

Parameters

  • values:

    A pointer to the constant values.

  • type:

    The data type of the function constants.

  • range:

    The range of the function constant indices.

Discussion

Declare multiple function constants in Metal Shading Language (MSL).

constant bool a [[ function_constant(0) ]];
constant bool b [[ function_constant(1) ]];
constant bool c [[ function_constant(2) ]];

Set their values by assigning an index range of an array.

let abc = [true, true, true]
let constantValues = MTLFunctionConstantValues()
constantValues.setConstantValues(abc,
                                 type: .bool,
                                 with: NSMakeRange(0, 3))

See Also

Setting constant values