I have the following scenario:
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 several OpenGL / CUDA interop tutorials and some of the steps of doing this are not completely clear to me.
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.
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.
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?
UPDATE:
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.
Map it to CUDA buffer resource.
Do changes to the data with a kernel.
Update target texture from modified PBO.
Use the updated texture in OpenGL .