Open chenw11 opened 3 years ago
It's been a while that I worked with OpenGL/Cuda interop but I can remember that together with multi-threading on CPU this ended up in a nightmare. My solution was to run all graphics and Cuda on a specific CPU thread. So instead of having api calls done directly on multiple host threads, I invoked them on a specific thread for Cuda/OpenGL. Of course this solution has performance draw backs, but for me it worked out fine... Maybe this can help you, too.
Referring to the provided ManagedCUDA example FluidsGLCSharp, I initialized a CudaGraphicsInteropResourceCollection as cuda_pbo_resource in the class constructor: However, I got the following error when tried to access the object from a different CPU thread. This method is an override method that constantly updates during the runtime: I tried to set the CUDA context to current thread using ctx.SetCurrent(), but the error retain the same. The only situation I can get it to work is placing the MapAllResources() right after the cuda_pbo_resource.Add() like the following: Seem like the OpenGL interop resource is not available for global share. Is there a way to set its property? The current bug info of this error is difficult to track the problem. Thanks in advance for your help.