Tomato Cycles: ability to cancel rendering before tile was fully rendered
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 23 Jul 2012 13:51:29 +0000 (13:51 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 23 Jul 2012 13:51:29 +0000 (13:51 +0000)
Seems this requred cuda context synchronization after every finished sample,
which could give few percent of slowdown. In test made here it was only minor
slowdown, so think it's pretty much acceptable for now.

intern/cycles/device/device_cuda.cpp

index c297d120b692ab005bb7ec9f2fec45dde3dce5c6..05d19ec106e789cd13aa284fd1415881c6e02a62 100644 (file)
@@ -531,6 +531,8 @@ public:
                cuda_assert(cuFuncSetBlockShape(cuPathTrace, xthreads, ythreads, 1))
                cuda_assert(cuLaunchGrid(cuPathTrace, xblocks, yblocks))
 
+               cuda_assert(cuCtxSynchronize())
+
                cuda_pop_context();
        }
 
@@ -834,12 +836,13 @@ public:
                                int start_sample = tile.start_sample;
                                int end_sample = tile.start_sample + tile.num_samples;
 
-                               for(int sample = start_sample; sample < end_sample; sample++)
-                                       path_trace(tile, sample);
+                               for(int sample = start_sample; sample < end_sample; sample++) {
+                                       if (task->get_cancel()) {
+                                               break;
+                                       }
 
-                               cuda_push_context();
-                               cuda_assert(cuCtxSynchronize())
-                               cuda_pop_context();
+                                       path_trace(tile, sample);
+                               }
 
                                task->release_tile(tile);
                        }