I started a raytracing project using the python numba library which provides a just-in-time compiler for CUDA kernels. When the scene is rendered my result is a 1920 x 1080 x 3 RGB array in GPU memory. If I only want to display a single image I can grab the result and save it to a .PNG file. My results are great so far, however, my long-term goal is to make a real-time engine with ray-tracing computations.

I am aware that python numba does not support CUDA - OPENGL interoperability, so currently I grab the image from CUDA, and then render it as a texture on the screen. This results in the raytracing being only 3% of computational time. (I can do 30 fps using python arcade and rendering one frame is about 1 ms.)

  • Is there a way to interface CUDA with DirectX/Vulkan/OpenGL to show what the GPU already has in memory?

If not, then I am ready to port the project to a different language and use a different API.

  • What library/API/language should I port this raytracing project to display my algorithm real-time on the screen?

PS: I am quite new to computer graphics, so I don't get the full picture yet.

  • $\begingroup$ I have found this: raytracing-docs.nvidia.com/optix_6_0/whitepaper/… where in section 4 they mention: " After execution of the ray tracing kernel has finished, its result data can be used by the application. Typically, this involves reading from output buffers filled by one of the user programs or displaying such a buffer directly, e.g., via OpenGL." Does anyone know how OpenGL would gain access to CUDA memory? $\endgroup$
    – Speterius
    Aug 19, 2019 at 22:26
  • $\begingroup$ This could also be what I'm looking for: devtalk.nvidia.com/default/topic/1024404/optix/… $\endgroup$
    – Speterius
    Aug 19, 2019 at 22:39
  • $\begingroup$ I think your only choice is CUDA-OpenGL interop. If python doesn't support it start working in C++. I believe python is more suited for data science kind of stuff. If you want to learn and implement graphics algorithms, C++ has more benefits as more APIs and libraries are available for it $\endgroup$ Aug 20, 2019 at 8:41
  • $\begingroup$ Will definitely port it to c++. I took it as a challenge to do this with as much python code as possible, but I have to go the interop direction. $\endgroup$
    – Speterius
    Aug 20, 2019 at 8:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.