I need to draw a line (light-source/light-target) with Metal on macOS within a 60 FPS animation while the two endpoints coordinates of the line change on each frame.
Actually I can properly draw a static line with Metal using a MTLBuffer containing just two fixed endpoints, but any transformation I apply on the line matrix affects both the endpoints, not each endpoint independently.
So how can a vary each of the two endpoints coordinates at each render pass? Is a way to modify the MTLBuffer at each frame? Should I pass the two coordinates to the shader through setVertexBytes: then use a different pipeline to draw this line?
I have found the solution. I modify the line MTLBuffer content at each render pass. I just set the 2 endpoints coordinates value then I set the vertexBuffer and draw the line.
The strange think is that my vertexBuffer is described as immutable while it seems that I can still flawlessly modify it.