I am trying to implement a simple realtime-raytracer with CUDA. So I need a very fast way of getting the rendered pixel to the backbuffer.
I use IDirect3DDevice9::GetBackBuffer() to get the surface-interface of the backbuffer. Now I may access to the data by using IDirect3DSurface9::LockRect with the CPU-program. But what I want is a pointer to the device-memory which I can use in a kernel to directly write my results. Is there any way of doing this?
Hi. I’m also working on something similar. I was wondering if you were able to solve this problem.
You can’t write directly to the framebuffer, but you can write to a D3D texture from CUDA and then display that. See the simpleD3D9 sample in the SDK.
But if you create an offscreen surface, write to it using CUDA, and then stretchrect it to the backbuffer, won’t that work? My impression is that it is simpler to work with off-screen surfaces than with textures, and I think they’re faster too. Is that right?
Also, I need to do this in full-screen mode since I want to create a stereoscopic image. Thanks.