How do you synchronize a Metal Performance Shader with an MTLBlitCommandEncoder?
Metal takes care of this for you. The driver and GPU execute commands in a command buffer as though in serial fashion. (The "as though" allows for running things in parallel or out of order for efficiency, but only if the result would be the same as when done serially.)
Synchronization issues arise when both the CPU and GPU are working with the same objects. Also with presenting textures on-screen. (You shouldn't be rendering to a texture that's being presented on screen.)
There's a section of the Metal Programming Guide which deals with read-write access to resources by shaders, which is not exactly the same, but should reassure you:
Between Command Encoders
All resource writes performed in a given command encoder are visible in the next command encoder. This is true for both render and compute command encoders.
Within a Render Command Encoder
For buffers, atomic writes are visible to subsequent atomic reads across multiple threads.
For textures, the
textureBarriermethod ensures that writes performed in a given draw call are visible to subsequent reads in the next draw call.
Within a Compute Command Encoder
All resource writes performed in a given kernel function are visible in the next kernel function.