From my code I have just found a problem with vbo and cuda,
- I change the data in VBO with opengl commands:
glBindBuffer( GL_ARRAY_BUFFER, _vbo_id );
GLfloat* unitdata = static_cast<GLfloat*>( glMapBuffer( GL_ARRAY_BUFFER, GL_READ_WRITE ) );
xxxx; /* change this VBO with pointer unitdata at host side */
glUnmapBuffer( GL_ARRAY_BUFFER );
glBindBuffer( GL_ARRAY_BUFFER, 0 );
- Then I wanna read this VBO from cuda:
cudaGraphicsMapResources( 1, &cgr, 0 ); /* cgr has already been initialized( registered with the corresponding VBO ID ) at the initialization phase /
cudaGraphicsResourceGetMappedPointer( &pdata, &datasizeinbyte, cgr );
xxxx; / using this vbo’s data in cuda(kernel) throught this mapped pointer */
cudaGraphicsUnmapResources( 1, &cgr, 0 );
But by my program, every time after I have changed the data in VBO with opengl, the data read from cuda remains unchanged. I am really confused about that, I have printed the data (coppied first to host memory side) every time I use the mapped pointer in kernel.
Please help me, thanks very much!