title: OpenGL - poor performance and incorrect results while updating texture in a loop using FBOs
body: <p>First of all:<br />Windows XP SP3, 2GB RAM, Intel core 2 Duo 2.33 GHz, nVidia 9600GT 1GB RAM. OpenGL 3.3 fully updated.</p>
  
  <p>Short description of what I am doing:<br />Ideally I need to put ONE single pixel in a GL texture (A) using glTexSubImage2D every frame.<br />Then, modify the texture inside a shader-FBO-quadfacingcamera setup and replace the original image with the resulting FBO.</p>
  
  <p>Of course, I don't want a FBO Feedback Loop, so instead I put the modified version inside a temporary texture and do the update separately with glCopyTexSubImage2D.</p>
  
  <p>The sequence is now:</p>
  
  <p>1) Put one pixel in a GL texture (A) using glTexSubImage2D every frame (with width=height=1).<br />2) This modified version A is to be used/modified inside a shader-FBO-quad setup to be rendered into a different texture (B).<br />3) The resulting texture B is to be overwritten over A using glCopyTexSubImage2D.<br />4) Repeat...</p>
  
  <p>By repeating this loop I want to achieve a slow fading effect by multiplying the color values in the shader by 0.99 every frame.</p>
  
  <p>2 things are badly wrong:<br />1) with a fading factor of 0.99 repeated every frame, the fading stops at RGB 48,48,48. Thus, leaving a trail of greyish pixels not fully faded out.<br />2) the program runs at 100 FPS. Very bad. Because if I comment out the glCopyTexSubImage2D the program goes at 1000 FPS!!</p>
  
  <p>I achieve 1000 FPS also by commenting out just glTexSubImage2D and leaving alone glCopyTexSubImage2D. This fact to clarify that glTexSubImage2D and glCopyTexSubImage2D are NOT the bottleneck by themselves (I tried to replace glCopyTexSubImage2D with a secondary FBO to do the copying, same results).</p>
  
  <p>Observation: the bottleneck shows when both those commands are working!</p>
  
  <p>Hard mode: no PBOs pls.</p>
  
  <p>Link with source and exe:<br /><a href="http://www.mediafire.com/?ymu4v042a1aaha3" rel="nofollow">http://www.mediafire.com/?ymu4v042a1aaha3</a><br />(CodeBlocks and SDL used)<br />FPS counts are written into stdout.txt</p>
  
  <p>I ask for a workaround for the 2 things exposed up there.<br />Expected results: full fade-out effect to plain black at 800-1000 FPS.</p>