Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display pixel arrays in GPU global memory onto screen directly?

Tags:

cuda

gpu

opengl

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?

like image 296
Tony Avatar asked Oct 22 '22 13:10

Tony


1 Answers

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.

like image 127
datenwolf Avatar answered Nov 01 '22 10:11

datenwolf