Cycles: Change the way how we pass requested capabilities to the device

Previously we only had experimental flag passed to device's load_kernel() which
was all fine. But since we're gonna to have some extra parameters passed there
it makes sense to wrap them into a single struct, which will make it easier to
pass stuff around.
This commit is contained in:
Sergey Sharybin 2015-05-09 19:05:49 +05:00
parent d69c80f717
commit 0e4ddaadd4
6 changed files with 40 additions and 12 deletions

@ -69,6 +69,22 @@ public:
}
};
class DeviceRequestedFeatures {
public:
/* Use experimental feature set. */
bool experimental;
DeviceRequestedFeatures()
{
experimental = false;
}
bool modified(const DeviceRequestedFeatures& requested_features)
{
return !(experimental == requested_features.experimental);
}
};
/* Device */
struct DeviceDrawParams {
@ -125,7 +141,9 @@ public:
virtual void *osl_memory() { return NULL; }
/* load/compile kernels, must be called before adding tasks */
virtual bool load_kernels(bool /*experimental*/) { return true; }
virtual bool load_kernels(
const DeviceRequestedFeatures& /*requested_features*/)
{ return true; }
/* tasks */
virtual int get_split_task_count(DeviceTask& task) = 0;

@ -309,18 +309,18 @@ public:
return cubin;
}
bool load_kernels(bool experimental)
bool load_kernels(const DeviceRequestedFeatures& requested_features)
{
/* check if cuda init succeeded */
if(cuContext == 0)
return false;
/* check if GPU is supported */
if(!support_device(experimental))
if(!support_device(requested_features.experimental))
return false;
/* get kernel */
string cubin = compile_kernel(experimental);
string cubin = compile_kernel(requested_features.experimental);
if(cubin == "")
return false;

@ -89,10 +89,10 @@ public:
return error_msg;
}
bool load_kernels(bool experimental)
bool load_kernels(const DeviceRequestedFeatures& requested_features)
{
foreach(SubDevice& sub, devices)
if(!sub.device->load_kernels(experimental))
if(!sub.device->load_kernels(requested_features))
return false;
return true;

@ -196,7 +196,7 @@ public:
}
}
bool load_kernels(bool experimental)
bool load_kernels(const DeviceRequestedFeatures& requested_features)
{
if(error_func.have_error())
return false;
@ -204,7 +204,7 @@ public:
thread_scoped_lock lock(rpc_lock);
RPCSend snd(socket, &error_func, "load_kernels");
snd.add(experimental);
snd.add(requested_features.experimental);
snd.write();
bool result;
@ -607,11 +607,11 @@ protected:
device->tex_free(mem);
}
else if(rcv.name == "load_kernels") {
bool experimental;
rcv.read(experimental);
DeviceRequestedFeatures requested_features;
rcv.read(requested_features.experimental);
bool result;
result = device->load_kernels(experimental);
result = device->load_kernels(requested_features);
RPCSend snd(socket, &error_func, "load_kernels");
snd.add(result);
snd.write();

@ -593,6 +593,13 @@ void Session::run_cpu()
update_progressive_refine(true);
}
DeviceRequestedFeatures Session::get_requested_device_features()
{
DeviceRequestedFeatures requested_features;
requested_features.experimental = params.experimental;
return requested_features;
}
void Session::load_kernels()
{
thread_scoped_lock scene_lock(scene->mutex);
@ -600,7 +607,7 @@ void Session::load_kernels()
if(!kernels_loaded) {
progress.set_status("Loading render kernels (may take a few minutes the first time)");
if(!device->load_kernels(params.experimental)) {
if(!device->load_kernels(get_requested_device_features())) {
string message = device->error_message();
if(message.empty())
message = "Failed loading render kernel, see console for errors";

@ -32,6 +32,7 @@ CCL_NAMESPACE_BEGIN
class BufferParams;
class Device;
class DeviceScene;
class DeviceRequestedFeatures;
class DisplayBuffer;
class Progress;
class RenderBuffers;
@ -204,6 +205,8 @@ protected:
bool update_progressive_refine(bool cancel);
vector<RenderBuffers *> tile_buffers;
DeviceRequestedFeatures get_requested_device_features();
};
CCL_NAMESPACE_END