title: Fast copy between two FBO(s) or from FBO to Texture in OpenGL-ES 1.1
body: <p>Greetings.</p>
  
  <p>My goal is to implement a pipeline for processing video frames that has a "current" and "previous" frame. It needs to copy a subregion from the "previous" frame into the "current" frame on some occasions. This is a kind of decoder which is part of a larger application.</p>
  
  <p>This is what I have running so far, on the iPhone using OpenGL-ES 1.1</p>
  
  <blockquote>
  <pre><code>                            glCopyTexSubImage2D
                          .--------------------\
    glTexSubImage2D       V     glDrawArray    |
  </code></pre>
    
    <p>image --------------------------> Texture --------------> FBO/Texture -------> render buffer</p>
  </blockquote>
  
  <p>The Texture gets each new frame or partial frame updated as usual.
  The Texture is drawn into the frame buffer object and eventually rendered.</p>
  
  <p>These parts perform very nicely.</p>
  
  <p>The problem is the glCopyTexSubImage2D, which profiled using Instruments shows that it takes about 50% of the CPU; it looks like it's doing the copy using the CPU. Yuck.</p>
  
  <p>Before I post the code (and I will happily do that), I wanted to ask if this architecture is sound?</p>
  
  <p>The next phase of the project is share the final FBO/Texture with another GL context to render to an external screen. I've read other posts here about the delicate nature of shared resources.</p>
  
  <p>Thanks for any guidance.</p>
  
  <p>Cheers, Chris</p>
  
  <p>P.S. I had some trouble getting the diagram to look right. The back-flow line should go from the FBO/Texture node to the Texture node.</p>