diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-09 17:15:58 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-09 17:17:49 +0300 |
commit | 17c95d0a96e306b2f38ff6e489064d6f021e494c (patch) | |
tree | 19289e9c2d18c13a0dee20e61b4a9db6e4673661 | |
parent | 5068f7dc015eb66a292d0027b3268f535201b3af (diff) |
Cycles: Add utility function to count maximum number of closures used by session
This will be used by split kernel in order to compile most optimal kernel.
Maximum number of closures is actually being cached in the session, so viewport
rendering will not trigger kernel re-loading when number of closures goes down.
-rw-r--r-- | intern/cycles/render/session.cpp | 15 | ||||
-rw-r--r-- | intern/cycles/render/session.h | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 9ef1c1f4f1f..cfd974346c3 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -20,6 +20,7 @@ #include "buffers.h" #include "camera.h" #include "device.h" +#include "graph.h" #include "integrator.h" #include "scene.h" #include "session.h" @@ -77,6 +78,9 @@ Session::Session(const SessionParams& params_) gpu_need_tonemap = false; pause = false; kernels_loaded = false; + + /* TODO(sergey): Check if it's indeed optimal value for the split kernel. */ + max_closure_global = 1; } Session::~Session() @@ -935,4 +939,15 @@ void Session::device_free() */ } +int Session::get_max_closure_count() +{ + int max_closures = 0; + for(int i = 0; i < scene->shaders.size(); i++) { + int num_closures = scene->shaders[i]->graph->get_num_closures(); + max_closures = max(max_closures, num_closures); + } + max_closure_global = max(max_closure_global, max_closures); + return max_closure_global; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h index cfce5360526..c669bccd34b 100644 --- a/intern/cycles/render/session.h +++ b/intern/cycles/render/session.h @@ -207,6 +207,14 @@ protected: vector<RenderBuffers *> tile_buffers; DeviceRequestedFeatures get_requested_device_features(); + + /* ** Split kernel routines ** */ + + /* Maximumnumber of closure during session lifetime. */ + int max_closure_global; + + /* Get maximum number of closures to be used in kernel. */ + int get_max_closure_count(); }; CCL_NAMESPACE_END |