Cuda-OpenGL-Interops-Thread-Sicherheit [geschlossen]C++

Programme in C++. Entwicklerforum
Guest
 Cuda-OpenGL-Interops-Thread-Sicherheit [geschlossen]

Post by Guest »

Code: Select all

/* This executes on a second thread */
static void do_progressive_render_gpu() {
for(sample s = 0 ; s < SOMEVALUE ; s++){
updateMeshBuffersPtrs(); //Calls cudaGraphicsResourceGetMappedPointer() down the call stack to get those VBOs arrays.
bake_scene_gpu(); // Launches a cuda kernel.
}
}

/* This executes on the main thread with the OpenGL context we use.
* The caller of this function has already registered the VBOs with cudaGraphicsGLRegisterBuffer()
*/
static void start_baking() {
std::function callback;
registerGraphicsResources(); // Calls cudaGraphicsResource
haltRenderers(); // This can be a solution to prevent OpenGL from accessing those resources, but I would prefer to avoid it if possible.
callback = []() { do_progressive_render_gpu(); };
std::thread worker_baking_thread(callback);
//...
//...
// Cleanup and unmap the resources on the main thread later
}
Dieser Code startet einen Cuda-Thread, der cudaGraphicsResourceGetMappedPointer() ausführt
Der Hauptthread hat die Cuda-Ressourcen bereits registriert und zugeordnet.
PS: Der Zugriff auf die GPU-Puffer ist schreibgeschützt.
Ist es threadsicher?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post