I'm doing a path tracer on GPU, and I got some traced results of pixel data (which is an array of float3) on GPU global memory, what I do to display the array on screen is to copy the array to CPU memory and call OpenGL glTexImage2D
:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixelArray);
then display the texture. pixelArray
is the pixel data array to show. As GPU is the device managing the whole rendering process, is there a way to display the pixelArray
on screen without copying data from GPU to CPU?
Use CUDA OpenGL graphics interop to map a OpenGL texture as CUDA global memory. Either write your data directly to the texture or use a cudaMemcpy2D.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With