/* 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
}
Этот код запускает поток cuda, который выполняет cudaGraphicsResourceGetMappedPointer()
Основной поток уже зарегистрировал и сопоставил ресурсы cuda.
/>PS: доступ к буферам графического процессора доступен только для чтения.
Это потокобезопасно?
[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] Этот код запускает поток cuda, который выполняет cudaGraphicsResourceGetMappedPointer() Основной поток уже зарегистрировал и сопоставил ресурсы cuda. />PS: доступ к буферам графического процессора доступен только для чтения. Это потокобезопасно?
/* This executes on a second thread */
static void do_progressive_render_gpu() {
for(sample s = 0 ; s PS: доступ к буферам графического процессора доступен только для чтения.
Это потокобезопасно?
/* This executes on a second thread */
static void do_progressive_render_gpu() {
for(sample s = 0 ; s PS: доступ к буферам графического процессора доступен только для чтения.
Это потокобезопасно?
/* This executes on a second thread */
static void do_progressive_render_gpu() {
for(sample s = 0 ; s PS: доступ к буферам графического процессора доступен только для чтения.
Это потокобезопасно?