0
votes

I'm trying to implement a point cloud with OpenGL and CUDA, where the radii of the points shall vary in size over time, based on some data associated with them.

Since I'm completely new to OpenGL AND CUDA, I'm having a pretty tough time achieving this goal. After learning the basics of OpenGL, GLSL and CUDA, I'm completely confused about which parts of the program should be achieved how.

My idea was the following:

  • Use a VBO with vertex positions
  • Use a VBO with vertex radii
  • Use a VBO with vertex uncertainties. Based on this data, the radii of the vertices shall vary in an animated manner
  • Compute the radius of all the vertices in a CUDA kernel each frame
  • Call glDrawArrays to render all the points and use a vertex shader, which gets all the data from the arrays as input

First of all...it is reasonable to use CUDA and GLSL shaders together for this purpose? Since I've read some things about using either one or the other, I'm not sure about that.

The second question is, which parts of the program would be executed on the CPU and which on the GPU? Does it make sense to calculate data in a kernel and then pass it back to the OpenGL display function to render it?

1

1 Answers

1
votes

First of all...it is reasonable to use CUDA and GLSL shaders together for this purpose? Since I've read some things about using either one or the other, I'm not sure about that.

No, it's not reasonable. If your goal is to get an image - use OpenGL. If your goal is to do some heavy computation (multiply big matrices, etc) - use CUDA.

You can compute radius of all vertices in vertex shader without CUDA at all. Use uniform variable to pass time information to shader. Pure OpenGL approach will be much faster since kernel launches and extra data transfer are not needed.

The second question is, which parts of the program would be executed on the CPU and which on the GPU? Does it make sense to calculate data in a kernel and then pass it back to the OpenGL display function to render it?

GLSL shaders and CUDA kernels are executed on GPU. Other code - on CPU. If you can calculate everything in rendering pipeline (and you can) there is no sence in CUDA launches.