title: Modifying OpenGL FBO texture attachment in CUDA
body: <p>I have the following scenario:</p>
  
  <p>I have custom FBO with texture as color attachment.I render my stuff into that FBO.Next step I need to share that texture with CUDA and then run on it some post-processing kernel.Afterwards  the texture should be bound back to a full screen quad and rendered to default Frame Buffer.
  I have read <a href="http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/Graphics_Interop.html" rel="nofollow">several OpenGL / CUDA interop tutorials</a> and some of the steps of doing this are not completely clear to me.</p>
  
  <p>First ,what I see they usually do is to read data from GL texture X ,process it in CUDA ,and then using PBO fill texture Y with resulting data.</p>
  
  <p>Another thing I noticed (correct me if I am wrong) is that the OpenGL in those demos use PBO bound by default and that means that the first pass rendering results are stored into it? I am really unsure about it as all those demos use fixed OpenGL and I see no place where PBO is bound when the initial geometry pass is rendered.</p>
  
  <p>So back to  my case:
  My final question is-can I operate directly on OpenGL texture in CUDA without using PBO so that I can modify it in CUDA kernel? 
  If no , then does it mean I have to pack FBO texture into PBO before passing it to CUDA stage? </p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Filling PBO from Frame buffer is usually done using glReadPixels(), which means it is downloaded to CPU.That is something I want to prevent.  - THAT WAS WRONG ASSUMPTION. So based on the fact I can fill PBO with pixels from texture is the following way to go?  :
  Fill PBO with data from texture.</p>
  
  <p>Map it to CUDA buffer resource.</p>
  
  <p>Do changes to the data with a kernel.</p>
  
  <p>Update target texture from  modified PBO.</p>
  
  <p>Use the updated texture in OpenGL  .</p>