Hi,

I'm currently facing some issues in passing a texture2d created via OSG to the 
CUDA low level driver API. I'm trying to run a cuda kernel on a texture after 
calling viewer->renderingTraversals();

As far as I have understood, all thats required is getting the underlaying 
texture ID for OpenGL and passing it to CUDA for further processing. However, I 
immediately get a segmentation fault when calling cuGraphicsGLRegisterImage. 
(Note: NOT a cuda error)
This in itself is already sort of weird, because to my understanding a CUDA 
call should either work or return a proper error code. Anyways...

Using the debugger, I validated the following:

"openGLContextID" is set to 0, which seems correct. Im not sure if I am 
retrieving the context ID in the correct way tough. Im using multiple cameras 
and let OSG manage the graphics context by itself (I never explicitly create 
it).

"texid" is set to 2.
"texid2" is set to 78.

I've also double checked the texture type, getTextureObject()->target() returns 
the same numerical value as GL_TEXTURE_2D, so it can't be that either.

I have tested all my code previously in an OpenGL only program, and it worked 
perfectly.

Does anyone know whats wrong? Am I executing the CUDA stuff at the wrong place? 
(After rendering)

Relevant code (error checking boilerplate removed for readability):


Code:
unsigned int openGLContextID =
                                
viewer->getCamera()->getGraphicsContext()->getState()->getContextID();
                GLenum texid = radarShaderOutputTexture->getTextureObject(
                                openGLContextID)->id();
                GLenum texid2 =
                                
cudaOutputTexture->getTextureObject(openGLContextID)->id();

                CUgraphicsResource cudaInputTex, cudaOutputTex;
                cuGraphicsGLRegisterImage(&cudaInputTex, texid,
                GL_TEXTURE_2D, CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY);
                cuGraphicsGLRegisterImage(&cudaOutputTex, texid2,
                GL_TEXTURE_2D, CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD);



Thank you!

Cheers,
Philipp

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=67637#67637





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to