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:
parent
5068f7dc01
commit
17c95d0a96
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user