Reputation: 78538
I am using OGRE for rendering some objects. At every frame, I would like to pass the resulting depth buffer to CUDA for running some kernels on it and computing a result.
How can I achieve this? How do I get access to the depth buffer in OGRE? How do I pass this to CUDA for processing? I do not need to write to the depth buffer in the CUDA kernels, it can be read-only.
Upvotes: 1
Views: 719
Reputation: 1766
Passing buffers from Ogre to CUDA is possible like this:
LPDIRECT3DDEVICE9 mDevice;
renderWindow->getCustomAttribute("D3DDEVICE", (void*) &mDevice);
Ogre::HardwareVertexBufferSharedPtr vbuf =
renderOp.vertexData->vertexBufferBinding->getBuffer(0); // or where your vertexData is stored.
Direct3DVertexBuffer9* mD3D9VertexBuffer_1 =
static_cast<Ogre::D3D9HardwareVertexBuffer*>(vbuf.get())->getD3D9VertexBuffer();
Now you can do a cudaMemcopy(). More info: http://www.ogre3d.org/forums/viewtopic.php?f=5&t=47003&sid=a0b22c741f015e2fdf0a5862d12d2020&start=25
I have this working for the vertex buffer. I am not sure if this works correctly with a DepthBuffer, but at least you can try: IDirect3DSurface9* Ogre::D3D9Device::getDepthBuffer ( D3D9RenderWindow * renderWindow )
. However I cannot find Information if this works or not (see http://www.ogre3d.org/docs/api/html/classOgre_1_1D3D9Device.html#a8e195a845ed22e0215d42abbc75d744e)
Upvotes: 2