I'm using a Metal compute kernel to generate mesh data (triangle soup, currently).
Is it possible to efficiently (without any copying) bring the mesh data into SceneKit to utilize SceneKit's renderer? The mesh data would be updated frequently, so avoiding copying of data is very important. The number of triangles may also change each frame.
you can pass a MTLBuffer to SCNGeometrySource (no copy):
+ (instancetype)geometrySourceWithBuffer:(id <MTLBuffer>)mtlBuffer vertexFormat:(MTLVertexFormat)vertexFormat semantic:(SCNGeometrySourceSemantic)semantic vertexCount:(NSInteger)vertexCount dataOffset:(NSInteger)offset dataStride:(NSInteger)stride API_AVAILABLE(macos(10.11), ios(9.0));
and you can adjust the number of elements dynamically (actually you can only crop, so you have to pre-allocate a buffer that is large enough) on SCNGeometryElement with:
@property(nonatomic) NSRange primitiveRange API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));