1
votes

I create an image with openGL and read it whit glReadPixels(). Now, I want to analyze that data. I want to parallelize the loop that run on each pixel and check its color by CUDA. The problem is that I need to pass the data from the GPU to the CPU and again to the GPU.

There is a way I can pass the data from glReadPixles() to CUDA without pass through the CPU?

can texture memory help me?

1
"The problem is that I need to pass the data from the GPU to the CPU and again to the GPU." - That is indeed a problem, since you don't need to do that at all. "There is a way I can pass the data from glReadPixles() to CUDA without pass through the CPU?" - No, glReadPixels doesn't have anything to do with it. Rather than that you should look into CUDA's features for OpenGL-interoperation, which can be gained from CUDA's documentation.Christian Rau

1 Answers

2
votes

You'll need to use the CUDA - OpenGL interop API.

There are a number of CUDA sample codes in the graphics and imaging sections that may be of interest.

The one I would suggest to start with is the gaussian blur sample, because I think the processing flow in it is close to what you are describing (modification of each pixel right before display).

You don't use glReadPixels because that does bring the data back to the CPU. Instead you register an openGL object with CUDA so it can be operated on by CUDA, then unregister it just prior to display.