Search code examples
iosopenclmetal

is there some method that like clCreateSubBuffer in Metal?


I am developing a iOS app and trying to use Metal to accelerate the computing speed.
I hope to compute data in different MTLBuffer and output into different segment of the same dest MTLBuffer. I know that in OpenCL i can use clCreateSubBuffer to access different parts of a buffer with different offsets. but i can not find such a method in Metal.
Any solution? or i just miss something?


Solution

  • Just bind the MTLBuffer to the MTLComputeCommandEncoder with a different offset:

    encoder.setBuffer(myBuffer, offset: XXX, index: 0)