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-09 20:58:01 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-01-09 20:58:01 +0400
commitd7932ceea82a3c2277a179c00ca72ecb3cfb97cb (patch)
tree933570102e52c7562b87534e87c0c38bb5eb47ec /intern/cycles/device/device_multi.cpp
parent47d9c6689be0448b898d18a1e810d2150867938b (diff)
Cycles: multi GPU rendering support.
The rendering device is now set in User Preferences > System, where you can choose between OpenCL/CUDA and devices. Per scene you can then still choose to use CPU or GPU rendering. Load balancing still needs to be improved, now it just splits the entire render in two, that will be done in a separate commit.
Diffstat (limited to 'intern/cycles/device/device_multi.cpp')
-rw-r--r--intern/cycles/device/device_multi.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index f8b512f209c..41d0e268526 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -163,15 +163,18 @@ public:
mem.device_pointer = tmp;
}
- void mem_copy_from(device_memory& mem, size_t offset, size_t size)
+ void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
{
device_ptr tmp = mem.device_pointer;
+ int i = 0, sub_h = h/devices.size();
- /* todo: how does this work? */
foreach(SubDevice& sub, devices) {
+ int sy = y + i*sub_h;
+ int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
+
mem.device_pointer = sub.ptr_map[tmp];
- sub.device->mem_copy_from(mem, offset, size);
- break;
+ sub.device->mem_copy_from(mem, sy, w, sh, elem);
+ i++;
}
mem.device_pointer = tmp;
@@ -332,37 +335,39 @@ Device *device_multi_create(DeviceInfo& info, bool background)
return new MultiDevice(info, background);
}
-static void device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool skip_display, const char *id_fmt, int num)
+static void device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool with_display, const char *id_fmt, int num)
{
DeviceInfo info;
/* create map to find duplicate descriptions */
map<string, int> dupli_map;
map<string, int>::iterator dt;
- int num_added = 0, num_skipped = 0;
+ int num_added = 0, num_display = 0;
foreach(DeviceInfo& subinfo, devices) {
if(subinfo.type == type) {
- if(skip_display && subinfo.display_device) {
- num_skipped++;
+ if(subinfo.display_device) {
+ if(with_display)
+ num_display++;
+ else
+ continue;
}
- else {
- string key = subinfo.description;
- if(dupli_map.find(key) == dupli_map.end())
- dupli_map[key] = 1;
- else
- dupli_map[key]++;
+ string key = subinfo.description;
- info.multi_devices.push_back(subinfo);
- if(subinfo.display_device)
- info.display_device = true;
- num_added++;
- }
+ if(dupli_map.find(key) == dupli_map.end())
+ dupli_map[key] = 1;
+ else
+ dupli_map[key]++;
+
+ info.multi_devices.push_back(subinfo);
+ if(subinfo.display_device)
+ info.display_device = true;
+ num_added++;
}
}
- if(num_added <= 1 || (skip_display && num_skipped == 0))
+ if(num_added <= 1 || (with_display && num_display == 0))
return;
/* generate string */
@@ -410,20 +415,24 @@ static void device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool
info.type = DEVICE_MULTI;
info.description = desc.str();
info.id = string_printf(id_fmt, num);
+ info.display_device = with_display;
info.num = 0;
- devices.push_back(info);
+ if(with_display)
+ devices.push_back(info);
+ else
+ devices.insert(devices.begin(), info);
}
void device_multi_info(vector<DeviceInfo>& devices)
{
int num = 0;
- device_multi_add(devices, DEVICE_CUDA, true, "CUDA_MULTI_%d", num++);
device_multi_add(devices, DEVICE_CUDA, false, "CUDA_MULTI_%d", num++);
+ device_multi_add(devices, DEVICE_CUDA, true, "CUDA_MULTI_%d", num++);
num = 0;
- device_multi_add(devices, DEVICE_OPENCL, true, "OPENCL_MULTI_%d", num++);
device_multi_add(devices, DEVICE_OPENCL, false, "OPENCL_MULTI_%d", num++);
+ device_multi_add(devices, DEVICE_OPENCL, true, "OPENCL_MULTI_%d", num++);
}
CCL_NAMESPACE_END