One problem I found when OpenGL buffer object used with CUDA in multiple rendering contexts.
When I have more than one rendering context, the opengl will return same buffer object ids for different buffer objects. The reason for returning same buffer object is nothing these are two rendering contexts.
See code below.
// Creating first buffer object with first rendering Context.
wglMakeCurrent( myRC1 );
glGenBuffers( 1, &myBuffer1 );// This id will be 1 in normal case.
// creating second buffer object with next rendering context.
wglMakeCurrent( myRC2 );
glGenBuffers( 1, &myBuffer2 );// This id also will be 1 in normal case.
// Then registering these buffers to CUDA.
cudaGLRegisterBufferObject( myBuffer1 ); // This will be success.
// Registering next buffer object.
cudaGLRegisterBufferObject( myBuffer2 ); // Here I’ll get Error .
The reason for this error is, cuda device depends on current thread. But openGL creates buffer objects based on rendering contexts. First register to cuda will succeeded, becouse its( 1) not registered yet. Then next register call will fail, becouse this buffer object id ( 1) is already registered for CUDA device. I created two rendering contexts for this thread and hence two buffer objects will return same id.
Thats all friends.
glStarter.
April 15, 2009 at 2:02 pm
After reading this article, I feel that I need more information on the topic. Could you suggest some resources please?
April 26, 2009 at 1:20 pm
CUDA is way to achieve GPGPU.
Please refer following link.
http://www.nvidia.com/object/cuda_what_is.html
U can learn more from NVIDIA s site.
June 25, 2009 at 10:29 am
Hi
I encountered this problem and solved it by using a tip I saw on the net by calling glGenBuffersARB(&dummyPBO) before generating the real PBO for the second context.
This way I don’t get the runtime error, but there is a very frustrating phenomenon in which the second window isn’t fully renderred but only about a quarter of it.
Have you encountered such a problem?
Do you have any idea about a possible reason?
Thanks.