title: Why is using multiple Pixel buffer Objects advised. Surely it is redundant?
body: <p><a href="http://www.songho.ca/opengl/gl_pbo.html" rel="noreferrer">This</a> article is commonly referenced when anyone asks about video streaming textures in OpenGL.</p>
  
  <p>It says:</p>
  
  <blockquote>
    <p>To maximize the streaming transfer performance, you may use multiple pixel buffer objects. The diagram shows that 2 PBOs are used simultaneously; glTexSubImage2D() copies the pixel data from a PBO while the texture source is being written to the other PBO. </p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/cNA4z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cNA4z.png" alt="Double PBO"></a></p>
  
  <blockquote>
    <p>For nth frame, PBO 1 is used for glTexSubImage2D() and PBO 2 is used to get new texture source. For n+1th frame, 2 pixel buffers are switching the roles and continue to update the texture. Because of asynchronous DMA transfer, the update and copy processes can be performed simultaneously. CPU updates the texture source to a PBO while GPU copies texture from the other PBO. </p>
  </blockquote>
  
  <p>They provide a simple bench-mark program which allows you to cycle between texture updates without PBO's, with a single PBO, and with two PBO's used as described above.</p>
  
  <p>I see a slight performance improvement when enabling one PBO.
  But the second PBO makes no real difference.</p>
  
  <p>Right before the code glMapBuffer's the PBO, it calls glBufferData with the pointer set to NULL. It does this to avoid a sync-stall.</p>
  
  <pre><code>// map the buffer object into client's memory
  // Note that glMapBufferARB() causes sync issue.
  // If GPU is working with this buffer, glMapBufferARB() will wait(stall)
  // for GPU to finish its job. To avoid waiting (stall), you can call
  // first glBufferDataARB() with NULL pointer before glMapBufferARB().
  // If you do that, the previous data in PBO will be discarded and
  // glMapBufferARB() returns a new allocated pointer immediately
  // even if GPU is still working with the previous data.
  </code></pre>
  
  <p>So, Here is my question...
  Doesn't this make the second PBO completely useless? Just a waste of memory !?</p>
  
  <p>With two PBO's the texture data is stored 3 times. 1 in the texture, and one in each PBO.</p>
  
  <p>With a single PBO. There are two copies of the data. And temporarily only a 3rd in the event that glMapBuffer creates a new buffer because the existing one is presently being DMA'ed to the texture?</p>
  
  <p>The comments seem to suggest that OpenGL drivers internally are capable to creating the second buffer IF and only WHEN it is required to avoid stalling the pipeline. The in-use buffer is being DMA'ed, and my call to map yields a new buffer for me to write to.</p>
  
  <p>The Author of that article appears to be more knowledgeable in this area than myself. Have I completely mis-understood the point?</p>