Compute shader or cuda in real time scenario.

Hi,
We have a real time graphics course in the uni where we have to programme a demo. The graphics rendering has to be done either in OpenGL or Direct3d. I was thinking of implementing some additional effects in CUDA and then using its interop functions to transfer the stuff to opengl.

But the teacher voiced concerns, that switching from opengl to cuda and back could be too slow, or at least would take away valuable time. We have to produce at least 60 frames per second. As an alternative he proposed compute shaders. I want to use output from opengl in cuda and then draw it again with opengl, so it would be really 2 switches.

I have no experience with compute shaders, and as far as I can tell, they are limited compared to cuda, lacking language features (classes, data structures, libs), debugging and profiling possibilities. But on the other hand, it would be probably enough for what I need.

So the main question is, whether the time needed for switching would be considerable in this scenario.

I found this on the forums https://devtalk.nvidia.com/default/topic/545337/cuda-kernel-or-opengl-compute-shader-/, but they are talking about path tracing, which is not real time most often.

There are several sample cuda apps that come with the Cuda toolkit that demonstrate cuda/graphics interop. SmokeParticles, oceanFFT, and nbody come to mind as good examples. All of them run at over 100fps on my system.

And if you’re looking to experiment with shaders, this site has some really cool examples of what can be achieved with just a small amount of code:

https://www.shadertoy.com/

I’m aware of those examples, but they use only simple rendering and need only one switch per frame (didn’t check the code, but looks like).

If switching took 1ms, it would take at 60fps only 6% of the time, which is still acceptable, but switching twice would take already 12%, which is quite much. I suppose, that switching time is rather hardware independent…

Edit: I just realised, that my case is no different no the interop examples. In either case there is one switch to cuda and one back. The difference is only on the first frame. But the question about measurements still holds.

I couldn’t open the shadertoys on the tablet, are there cuda or glsl shaders?

Does anybody have measurements about the switching time?