/* 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 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 habe eine Frage zu Linux -Befehlen. Zum Beispiel ist die Originaldatei A. Als ich Cp -r verwendete, war das Ergebnis B, und als ich CP -Al verwendete, war das Ergebnis C.
, dass A und C genau die...