I am presently trying to integrate Nvidia Optix into Ogre3D as part of my application framework. Mostly so I can play around with raytracing, where the output can be rendered to any object via an Ogre::Material. The intention is that Optix renders directly into the hardware pixel buffer of the texture associated with the material, by using CUDA-OpenGL interop. Then the material can be attached to anything; overlays, billboards, geometry etc.
I am able to create the Optix context, create an optix rendering output buffer using the textures GL tex ID, load PTX programs, validate and compile etc, all without problems. However launching causes a crash in the OpenGL video driver, returning "Error code 3." If I had to guess probably this is something to do with how Ogre creates the hardware pixel buffer for the texture that isn't playing well with Optix.
So I am wondering if anyone has experience with Ogre3D + Optix/CUDA and might know about how to deal with buffers.
I am creating the Ogre::Texture like this:
Code: Select all
mpRenderSystemTexture = Ogre::TextureManager::getSingleton().createManual( mRenderSystemTextureName,
LIBAPP_OGRE_RESOURCE_GROUP_NAME, // use app base resource group
Ogre::TEX_TYPE_2D, // 2d texture
mPanelSize.getX(), // texture size = GUI panel size
mPanelSize.getY(),
0, // no mip mapping for interface texture
Ogre::PF_FLOAT32_RGBA, // FLOAT32 RGBA buffer format (Optix FLOAT4)
// set as a render-target, since rendering to texture.
Ogre::TU_RENDERTARGET);
The Ogre hardware pixel buffer is associated with Optix basically like this:
Code: Select all
unsigned int texGL_ID = static_cast<Ogre::GLTexturePtr>(mpRenderSystemTexture )->getGLID();
mOptixOutputBuffer = mOptixContext->createBufferFromGLBO(RT_BUFFER_OUTPUT, texGL_ID); // using RT_BUFFER_OUTPUT as GPU is writing to the output buffer only
mOptixOutputBuffer->setFormat(RT_FORMAT_FLOAT4); // RT_FORMAT_FLOAT4 to match Ogre::PF_FLOAT32_RGBA for texture format. this should automatically set element size to 128 bits.
mOptixOutputBuffer->setSize(mpRenderSystemTexture->getWidth(), mpRenderSystemTexture->getHeight()); // set buffer to same size as texture
Code: Select all
Unknown error (Details: Function "_rtContextLaunch2D" caught exception: Encountered a CUDA error: Kernel launch returned (999): Unknown, [6619200])
At this point I am pretty stumped. I figure I need to know more about Ogre hardware buffers to get this working.
So if anyone has any ideas, please do tell.