Hi,
I'd like to save the result of Metal rendering as an image file. I just tried something, and it worked, but I probably got lucky.
In response to a tap on a 'save image' button:
1. In the next call to MTKView delegate's `draw(in:)`, I keep a reference to the MTLTexture from my MTKView's `currentRenderPassDescriptor.colorAttachments[0].texture`
2. `commandBuffer.addCompletionHandler { _ in finishSave() }
3. In `finishSave()` I convert the MTLTexture from step 1 to a CIImage -> CGImage -> PNG file.
Should I be creating a second color attachment texture instead, and writing to that second texture in my fragment shader? Possible problems with above... maybe that texture is in the process of being overwritten when I try to save it? Or maybe it's not always readable by CPU?
thanks,
Rob