CUDA, OpenGL, multiple OpenGL contexts

Hi,

I have multiple textures that are registered using OpenGL interop. I’m rendering to them using CUDA (for context - I’m doing volume rendering using raytracing). Each my OpenGL texture is in different OpenGL context.

The question is - how should I do selection of current OpenGL contexts?

Currently I do like this:

  1. When I register or unregister texture in OpenGL interop - I select appropriate OpenGL context (the context that texture belongs to).
  2. When I map, unmap, access the registered resource - I do not select the appropriate OpenGL context (there is some context active, but not neccessary the same as the context that texture belongs to).

This works. But, I have some very strange bugs, and this pushes me to think of possible problems relative to this.

[b]For those who will get similar question. I have found problem in different place. And regardless the context selection it seems to:

  1. You must select appropriate context when registering/unregistering OpenGL resource.
  2. This is not neccessary to select appropriate context when mapping/unmapping this resource.[/b]