I am creating an OpenGL texture like this:
glGenTextures( 1, &board );
glBindTexture( GL_TEXTURE_2D, board );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
I get a handle at <i>board</i>
so I assume the texture’s been successfully created. I want to share this texture with CUDA so I register and map the resource:
cudaGLSetGLDevice(0);
cudaGraphicsGLRegisterImage( &boardImage, boardTex, GL_TEXTURE_2D, cudaGraphicsMapFlagsNone );
cudaGraphicsMapResources( 1, &boardImage, 0 );
Then I try to get the mapped pointer like this:
float4* mappedPointer;
size_t mappedSize;
cudaGraphicsResourceGetMappedPointer( (void**)&mappedPointer, &mappedSize, boardImage );
Unfortunately this call returns an error and refuses to work. I made sure the texture wasn’t bound in OpenGL context just in case. Still not working. <i>cudaGetErrorString</i>
yields “unknown error” so I’m pretty stuck here. I’d appreciate any ideas.