Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-01-04 22:06:32 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-01-04 22:06:32 +0400
commit049ab984697aa277c476833670275624c4385257 (patch)
tree28f01921f0372247a669b36fd4877d3011a1f73e /intern/cycles/app
parentcd84a43334f59d9ff613a240467bbec5c882b7da (diff)
Cycles: device code refactoring, no functional changes.
Diffstat (limited to 'intern/cycles/app')
-rw-r--r--intern/cycles/app/cycles_server.cpp31
-rw-r--r--intern/cycles/app/cycles_test.cpp54
2 files changed, 65 insertions, 20 deletions
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<DeviceType> types = Device::available_types();
+ vector<DeviceType>& 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<DeviceInfo>& 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<DeviceInfo>& 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;
diff --git a/intern/cycles/app/cycles_test.cpp b/intern/cycles/app/cycles_test.cpp
index d9386f75141..0b8853d7036 100644
--- a/intern/cycles/app/cycles_test.cpp
+++ b/intern/cycles/app/cycles_test.cpp
@@ -203,17 +203,18 @@ static void options_parse(int argc, const char **argv)
options.session = NULL;
options.quiet = false;
- /* devices */
- string devices = "";
+ /* device names */
+ string device_names = "";
string devicename = "cpu";
+ bool list = false;
- vector<DeviceType> types = Device::available_types();
+ vector<DeviceType>& types = Device::available_types();
foreach(DeviceType type, types) {
- if(devices != "")
- devices += ", ";
+ if(device_names != "")
+ device_names += ", ";
- devices += Device::string_from_type(type);
+ device_names += Device::string_from_type(type);
}
/* shading system */
@@ -230,7 +231,7 @@ static void options_parse(int argc, const char **argv)
ap.options ("Usage: cycles_test [options] file.xml",
"%*", files_parse, "",
- "--device %s", &devicename, ("Devices to use: " + devices).c_str(),
+ "--device %s", &devicename, ("Devices to use: " + device_names).c_str(),
"--shadingsys %s", &ssname, "Shading system to use: svm, osl",
"--background", &options.session_params.background, "Render in background, without user interface",
"--quiet", &options.quiet, "In background mode, don't print progress messages",
@@ -239,6 +240,7 @@ static void options_parse(int argc, const char **argv)
"--threads %d", &options.session_params.threads, "CPU Rendering Threads",
"--width %d", &options.width, "Window width in pixel",
"--height %d", &options.height, "Window height in pixel",
+ "--list-devices", &list, "List information about all available devices",
"--help", &help, "Print help message",
NULL);
@@ -247,26 +249,44 @@ static void options_parse(int argc, const char **argv)
ap.usage();
exit(EXIT_FAILURE);
}
+ else if(list) {
+ vector<DeviceInfo>& devices = Device::available_devices();
+ printf("Devices:\n");
+
+ foreach(DeviceInfo& info, devices) {
+ printf(" %s%s\n",
+ info.description.c_str(),
+ (info.display_device)? " (display)": "");
+ }
+
+ exit(EXIT_SUCCESS);
+ }
else if(help || options.filepath == "") {
ap.usage();
exit(EXIT_SUCCESS);
}
- options.session_params.device_type = Device::type_from_string(devicename.c_str());
-
if(ssname == "osl")
options.scene_params.shadingsystem = SceneParams::OSL;
else if(ssname == "svm")
options.scene_params.shadingsystem = SceneParams::SVM;
- /* handle invalid configurations */
- bool type_available = false;
-
- foreach(DeviceType dtype, types)
- if(options.session_params.device_type == dtype)
- type_available = true;
+ /* find matching device */
+ DeviceType device_type = Device::type_from_string(devicename.c_str());
+ vector<DeviceInfo>& devices = Device::available_devices();
+ DeviceInfo device_info;
+ bool device_available = false;
+
+ foreach(DeviceInfo& device, devices) {
+ if(device_type == device.type) {
+ options.session_params.device = device;
+ device_available = true;
+ break;
+ }
+ }
- if(options.session_params.device_type == DEVICE_NONE || !type_available) {
+ /* handle invalid configurations */
+ if(options.session_params.device.type == DEVICE_NONE || !device_available) {
fprintf(stderr, "Unknown device: %s\n", devicename.c_str());
exit(EXIT_FAILURE);
}
@@ -278,7 +298,7 @@ static void options_parse(int argc, const char **argv)
fprintf(stderr, "Unknown shading system: %s\n", ssname.c_str());
exit(EXIT_FAILURE);
}
- else if(options.scene_params.shadingsystem == SceneParams::OSL && options.session_params.device_type != DEVICE_CPU) {
+ else if(options.scene_params.shadingsystem == SceneParams::OSL && options.session_params.device.type != DEVICE_CPU) {
fprintf(stderr, "OSL shading system only works with CPU device\n");
exit(EXIT_FAILURE);
}