/* 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?
[code]/* 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 } [/code] 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?
Ich habe Nvidia-Driver-580 und cuda-tools-13 auf Debian Trixie installiert (beide sind die neueste Version, die ich finden kann): $ a p t l i s t - - i n s t a l l e d | a g n v i d i a f i r m w a r...
Ich versuche, LWJGL mit dem Beispiel für das Erstensanschluss zu verwenden (von {welche unveränderte Funktionen gut funktionieren}), aber es wird OpenGL es 3.0 verwendet (aus Gründen, die irrelevant...
Ich bin ziemlich früh in den Versuch, einige Bildmanipulationsaufgaben auf einem kopflosen eingebetteten Gerät zu erledigen, das Linux mit einer Mali 400 -GPU ausgeführt wird. Dies unterstützt OpenGL...