~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/cycles/device/device_multi.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "device_intern.h"
24
24
#include "device_network.h"
25
25
 
 
26
#include "buffers.h"
 
27
 
26
28
#include "util_foreach.h"
27
29
#include "util_list.h"
28
30
#include "util_map.h"
44
46
        list<SubDevice> devices;
45
47
        device_ptr unique_ptr;
46
48
 
47
 
        MultiDevice(DeviceInfo& info, bool background_)
48
 
        : unique_ptr(1)
 
49
        MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
 
50
        : Device(stats), unique_ptr(1)
49
51
        {
50
52
                Device *device;
51
53
                background = background_;
52
54
 
53
55
                foreach(DeviceInfo& subinfo, info.multi_devices) {
54
 
                        device = Device::create(subinfo, background);
 
56
                        device = Device::create(subinfo, stats, background);
55
57
                        devices.push_back(SubDevice(device));
56
58
                }
57
59
 
255
257
                rgba.device_pointer = tmp;
256
258
        }
257
259
 
 
260
        void map_tile(Device *sub_device, RenderTile& tile)
 
261
        {
 
262
                foreach(SubDevice& sub, devices) {
 
263
                        if(sub.device == sub_device) {
 
264
                                if(tile.buffer) tile.buffer = sub.ptr_map[tile.buffer];
 
265
                                if(tile.rng_state) tile.rng_state = sub.ptr_map[tile.rng_state];
 
266
                                if(tile.rgba) tile.rgba = sub.ptr_map[tile.rgba];
 
267
                        }
 
268
                }
 
269
        }
 
270
 
 
271
        int device_number(Device *sub_device)
 
272
        {
 
273
                int i = 0;
 
274
 
 
275
                foreach(SubDevice& sub, devices) {
 
276
                        if(sub.device == sub_device)
 
277
                                return i;
 
278
                        i++;
 
279
                }
 
280
 
 
281
                return -1;
 
282
        }
 
283
 
258
284
        void task_add(DeviceTask& task)
259
285
        {
260
 
                ThreadQueue<DeviceTask> tasks;
 
286
                list<DeviceTask> tasks;
261
287
                task.split(tasks, devices.size());
262
288
 
263
289
                foreach(SubDevice& sub, devices) {
264
 
                        DeviceTask subtask;
 
290
                        if(!tasks.empty()) {
 
291
                                DeviceTask subtask = tasks.front();
 
292
                                tasks.pop_front();
265
293
 
266
 
                        if(tasks.worker_wait_pop(subtask)) {
267
294
                                if(task.buffer) subtask.buffer = sub.ptr_map[task.buffer];
268
 
                                if(task.rng_state) subtask.rng_state = sub.ptr_map[task.rng_state];
269
295
                                if(task.rgba) subtask.rgba = sub.ptr_map[task.rgba];
270
296
                                if(task.shader_input) subtask.shader_input = sub.ptr_map[task.shader_input];
271
297
                                if(task.shader_output) subtask.shader_output = sub.ptr_map[task.shader_output];
288
314
        }
289
315
};
290
316
 
291
 
Device *device_multi_create(DeviceInfo& info, bool background)
 
317
Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
292
318
{
293
 
        return new MultiDevice(info, background);
 
319
        return new MultiDevice(info, stats, background);
294
320
}
295
321
 
296
322
static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool with_display, bool with_advanced_shading, const char *id_fmt, int num)
303
329
        int num_added = 0, num_display = 0;
304
330
 
305
331
        info.advanced_shading = with_advanced_shading;
 
332
        info.pack_images = false;
306
333
 
307
334
        foreach(DeviceInfo& subinfo, devices) {
308
335
                if(subinfo.type == type) {
325
352
                        info.multi_devices.push_back(subinfo);
326
353
                        if(subinfo.display_device)
327
354
                                info.display_device = true;
 
355
                        info.pack_images = info.pack_images || subinfo.pack_images;
328
356
                        num_added++;
329
357
                }
330
358
        }