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.
This commit is contained in:
Sergey Sharybin 2015-05-09 19:15:58 +05:00
parent 5068f7dc01
commit 17c95d0a96
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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