Metal Best Practices Guide states that
The setVertexBytes:length:atIndex: method is the best option for binding a very small amount (less than 4 KB) of dynamic buffer data to a vertex function
I believe this means that in case of simple scenes, instead of storing uniforms in a manually managed dynamic buffer, it's best to simply update model/view/projection matrices without using any buffer at all, by using
setVertexBytes and setFragmentBytes.My question is, that in this case, as there is no dynamic buffer at all (only static vertex data), what are we calling triple buffering?
Is it simply because we have a semaphore with
value: 3 left now?Moreover, what if I totally remove the semaphore as well? The app seems to work fine. But what is happening in this case actually? Am I getting better latency or worse, compared to a semaphore with value: 3?
Since the render loop is limited to 60 FPS and the frame time is about 1.5 ms for the CPU (in case of a simple example), some command has to take the place of the blocking semaphore, right? Is Metal going into double-buffering in this case (GPU displays one frame while CPU is encoding the next)?
Well, technically there are dynamic buffers. They are created "behind the scenes" for you by Metal. There is no need for any synchronization, because all the buffers are created once with content sent by CPU, then used by GPU once and discarted. Similar technique was called buffer "orphaning" in OpenGL, I believe.
You can get rid of semaphores. There is no "triple" buffering, or any "n" buffering, since there is no fixed number of buffers being re-used. Technically, memory is of course (or you'd run out of it eventually), but not buffers.
Better or worse latency...well, the way I understand it (not sure if 100% correct) is that for small amounts of data (they say 4kb which happens to be page size on at least Intel CPUs) it doesn't matter whether you send only a few bytes, or say 3kb (from CPU to GPU). So instead of sending just a draw command, you pass along associated data, and as long as that data is small, there is no additional cost involved. So this is as fast as it gets.
Renderers usually double (or more) buffer they output, yes. But do not confuse output (render) double buffering (meant to avoid writing to the drawable being displayed, to avoid so called "tearing" artifacts) and upload (from CPU to GPU) many-buffering. It is not the same.
Hope that helps
Michal