Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2020-09-24 01:37:23 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2020-10-31 03:57:39 +0300
commit517ff40b124bc9d1324ccf7561a59ac51bf86602 (patch)
tree96295b1b6a11a597f7927cc61ce9371077bc7e54 /intern/cycles/render/session.h
parent523414dda2bf81b69b1c04e1145ac21758fa4268 (diff)
Cycles: Implement tile stealing to improve CPU+GPU rendering performance
While Cycles already supports using both CPU and GPU at the same time, there currently is a large problem with it: Since the CPU grabs one tile per thread, at the end of the render the GPU runs out of new work but the CPU still needs quite some time to finish its current times. Having smaller tiles helps somewhat, but especially OpenCL rendering tends to lose performance with smaller tiles. Therefore, this commit adds support for tile stealing: When a GPU device runs out of new tiles, it can signal the CPU to release one of its tiles. This way, at the end of the render, the GPU quickly finishes the remaining tiles instead of having to wait for the CPU. Thanks to AMD for sponsoring this work! Differential Revision: https://developer.blender.org/D9324
Diffstat (limited to 'intern/cycles/render/session.h')
-rw-r--r--intern/cycles/render/session.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index a22bf7731ae..770d3124db7 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -193,6 +193,8 @@ class Session {
bool render_need_denoise(bool &delayed);
+ bool steal_tile(RenderTile &tile, Device *tile_device, thread_scoped_lock &tile_lock);
+ bool get_tile_stolen();
bool acquire_tile(RenderTile &tile, Device *tile_device, uint tile_types);
void update_tile_sample(RenderTile &tile);
void release_tile(RenderTile &tile, const bool need_denoise);
@@ -217,11 +219,22 @@ class Session {
thread_mutex buffers_mutex;
thread_mutex display_mutex;
thread_condition_variable denoising_cond;
+ thread_condition_variable tile_steal_cond;
double reset_time;
double last_update_time;
double last_display_time;
+ RenderTile stolen_tile;
+ typedef enum {
+ NOT_STEALING, /* There currently is no tile stealing in progress. */
+ WAITING_FOR_TILE, /* A device is waiting for another device to release a tile. */
+ RELEASING_TILE, /* A device has releasing a stealable tile. */
+ GOT_TILE /* A device has released a stealable tile, which is now stored in stolen_tile. */
+ } TileStealingState;
+ std::atomic<TileStealingState> tile_stealing_state;
+ int stealable_tiles;
+
/* progressive refine */
bool update_progressive_refine(bool cancel);
};