<p>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.</p>

<p>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.)</p>

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

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

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

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

CC BY-SA 4.0
2019-08-19T22:26:10.607Z
I have found this: 

https://raytracing-docs.nvidia.com/optix_6_0/whitepaper/nvidia_optix_TOG_v29_n4.pdf

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?
Speterius
CC BY-SA 4.0
2019-08-19T22:39:31.853Z
This could also be what I'm looking for: https://devtalk.nvidia.com/default/topic/1024404/optix/binding-an-optixtexture-to-opengl/
Speterius
CC BY-SA 4.0
2019-08-20T08:41:32.043Z
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
gallickgunner
CC BY-SA 4.0
2019-08-20T08:47:41.770Z
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.
Speterius
<raytracing><rendering><real-time><cuda>
How to display image from CUDA / What API to port my project to for real-time raytracing?
Speterius
# How to display image from CUDA / What API to port my project to for real-time raytracing?

(Asked by: username_0 on 2019-08-19)

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.

**Tags:** raytracing, rendering, real-time, cuda

> **Comments:**
> **username_0**: I have found this:   https://raytracing-docs.nvidia.com/optix_6_0/whitepaper/nvidia_optix_TOG_v29_n4.pdf  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?  
> **username_0**: This could also be what I'm looking for: https://devtalk.nvidia.com/default/topic/1024404/optix/binding-an-optixtexture-to-opengl/  
> **username_1**: 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  
> **username_0**: 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.  

---

## 0 answers

