From 049ab984697aa277c476833670275624c4385257 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Jan 2012 18:06:32 +0000 Subject: Cycles: device code refactoring, no functional changes. --- intern/cycles/app/cycles_server.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'intern/cycles/app/cycles_server.cpp') diff --git a/intern/cycles/app/cycles_server.cpp b/intern/cycles/app/cycles_server.cpp index bcf4d3ea769..e6a13e04b48 100644 --- a/intern/cycles/app/cycles_server.cpp +++ b/intern/cycles/app/cycles_server.cpp @@ -34,8 +34,9 @@ int main(int argc, const char **argv) /* device types */ string devices = ""; string devicename = "cpu"; + bool list = false; - vector types = Device::available_types(); + vector& types = Device::available_types(); foreach(DeviceType type, types) { if(devices != "") @@ -49,6 +50,7 @@ int main(int argc, const char **argv) ap.options ("Usage: cycles_server [options]", "--device %s", &devicename, ("Devices to use: " + devices).c_str(), + "--list-devices", &list, "List information about all available devices", NULL); if(ap.parse(argc, argv) < 0) { @@ -56,11 +58,34 @@ int main(int argc, const char **argv) ap.usage(); exit(EXIT_FAILURE); } + else if(list) { + vector& devices = Device::available_devices(); - DeviceType dtype = Device::type_from_string(devicename.c_str()); + printf("Devices:\n"); + + foreach(DeviceInfo& info, devices) { + printf(" %s%s\n", + info.description.c_str(), + (info.display_device)? " (display)": ""); + } + + exit(EXIT_SUCCESS); + } + + /* find matching device */ + DeviceType device_type = Device::type_from_string(devicename.c_str()); + vector& devices = Device::available_devices(); + DeviceInfo device_info; + + foreach(DeviceInfo& device, devices) { + if(device_type == device.type) { + device_info = device; + break; + } + } while(1) { - Device *device = Device::create(dtype); + Device *device = Device::create(device_info); printf("Cycles Server with device: %s\n", device->description().c_str()); device->server_run(); delete device; -- cgit v1.2.3