My platform is Windows PC and C++. I am using an image buffer in GPU video memory via CUDA. Is there any way to directly send the content to GPU for display? Currently, I am getting the content into system memory and then use API function (such as GDI, OpenGL. DirectX) to send it back to GPU for display. I wonder if there is a faster way to do this.
You can bind a CUDA array as a texture, and then use that texture for rendering. There are restrictions on valid texture formats, and limits imposed on CUDA arrays to make this all work, but it does.
The specific API call in CUDA varies by which graphic API you're using, but look for "register resource."
Basically, create the texture with the appropriate image data like you wanted to render it (say, with D3D's
CreateTexture or GL's
glTexSubData2D). Register the texture with CUDA using the appropriate API (
cudaGraphicsGLRegisterImage for OpenGL). Bind the registered texture to a CUDA array (
Do the same for your render buffer (output texture, FBO bound in GL or
RenderTarget bound in D3D, using slightly different methods to bind/map it to CUDA - see the docs). Run your kernel. Bind the output texture for rendering in API of choice. Render using it as source, e.g. as a full-screen quad.
A not-great but not-terrible article with OpenGL integration with CUDA is on 3dgep.com.
Maybe this might not be of use to you, but Direct Compute will let you create a UAV (which can be used to calculate stuff onto, aswell as render to the display.
Direct Compute is staright forward and isent much of hassle to implement. i have used this myself when doing GPGPU stuff.