2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "device/device.h"
|
|
|
|
#include "device/device_intern.h"
|
|
|
|
#include "device/device_network.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "render/buffers.h"
|
2012-09-04 13:29:07 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_foreach.h"
|
|
|
|
#include "util/util_list.h"
|
|
|
|
#include "util/util_logging.h"
|
|
|
|
#include "util/util_map.h"
|
|
|
|
#include "util/util_time.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class MultiDevice : public Device
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct SubDevice {
|
2016-05-11 14:50:10 +00:00
|
|
|
explicit SubDevice(Device *device_)
|
2011-04-27 11:58:34 +00:00
|
|
|
: device(device_) {}
|
|
|
|
|
|
|
|
Device *device;
|
|
|
|
map<device_ptr, device_ptr> ptr_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
list<SubDevice> devices;
|
|
|
|
device_ptr unique_ptr;
|
|
|
|
|
2012-11-05 08:04:57 +00:00
|
|
|
MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
|
2013-12-07 01:29:53 +00:00
|
|
|
: Device(info, stats, background_), unique_ptr(1)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
Device *device;
|
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
foreach(DeviceInfo& subinfo, info.multi_devices) {
|
2016-09-23 10:43:23 +00:00
|
|
|
device = Device::create(subinfo, sub_stats_, background);
|
2011-04-27 11:58:34 +00:00
|
|
|
devices.push_back(SubDevice(device));
|
|
|
|
}
|
|
|
|
|
2013-12-07 01:29:53 +00:00
|
|
|
#ifdef WITH_NETWORK
|
2011-04-27 11:58:34 +00:00
|
|
|
/* try to add network devices */
|
|
|
|
ServerDiscovery discovery(true);
|
|
|
|
time_sleep(1.0);
|
|
|
|
|
2013-12-07 01:29:53 +00:00
|
|
|
vector<string> servers = discovery.get_server_list();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(string& server, servers) {
|
2013-12-07 01:29:53 +00:00
|
|
|
device = device_network_create(info, stats, server.c_str());
|
2011-04-27 11:58:34 +00:00
|
|
|
if(device)
|
|
|
|
devices.push_back(SubDevice(device));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
~MultiDevice()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
delete sub.device;
|
|
|
|
}
|
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
const string& error_message()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device->error_message() != "") {
|
|
|
|
if(error_msg == "")
|
|
|
|
error_msg = sub.device->error_message();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
}
|
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 03:22:34 +00:00
|
|
|
virtual bool show_samples() const
|
|
|
|
{
|
|
|
|
if(devices.size() > 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return devices.front().device->show_samples();
|
|
|
|
}
|
|
|
|
|
2015-05-09 14:05:49 +00:00
|
|
|
bool load_kernels(const DeviceRequestedFeatures& requested_features)
|
2011-09-12 13:13:56 +00:00
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
2015-05-09 14:05:49 +00:00
|
|
|
if(!sub.device->load_kernels(requested_features))
|
2011-09-12 13:13:56 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-12-14 01:45:09 +00:00
|
|
|
void mem_alloc(const char *name, device_memory& mem, MemoryType type)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
2016-12-14 01:45:09 +00:00
|
|
|
sub.device->mem_alloc(name, mem, type);
|
2011-04-27 11:58:34 +00:00
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
2016-09-23 10:43:23 +00:00
|
|
|
stats.mem_alloc(mem.device_size);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mem_copy_to(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_copy_to(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
2012-01-09 16:58:01 +00:00
|
|
|
int i = 0, sub_h = h/devices.size();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
2012-01-09 16:58:01 +00:00
|
|
|
int sy = y + i*sub_h;
|
|
|
|
int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
2012-01-09 16:58:01 +00:00
|
|
|
sub.device->mem_copy_from(mem, sy, w, sh, elem);
|
|
|
|
i++;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_zero(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_zero(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_free(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
2017-02-20 10:02:19 +00:00
|
|
|
stats.mem_free(mem.device_size);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void const_copy_to(const char *name, void *host, size_t size)
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->const_copy_to(name, host, size);
|
|
|
|
}
|
|
|
|
|
2015-07-28 11:51:10 +00:00
|
|
|
void tex_alloc(const char *name,
|
|
|
|
device_memory& mem,
|
|
|
|
InterpolationType
|
|
|
|
interpolation,
|
|
|
|
ExtensionType extension)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2016-05-29 22:02:05 +00:00
|
|
|
VLOG(1) << "Texture allocate: " << name << ", "
|
|
|
|
<< string_human_readable_number(mem.memory_size()) << " bytes. ("
|
|
|
|
<< string_human_readable_size(mem.memory_size()) << ")";
|
2015-04-10 10:36:56 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
2015-07-28 11:51:10 +00:00
|
|
|
sub.device->tex_alloc(name, mem, interpolation, extension);
|
2011-04-27 11:58:34 +00:00
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
2016-09-23 10:43:23 +00:00
|
|
|
stats.mem_alloc(mem.device_size);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tex_free(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
2017-02-20 10:02:19 +00:00
|
|
|
stats.mem_free(mem.device_size);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->tex_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_alloc(device_memory& mem)
|
|
|
|
{
|
2011-09-12 13:13:56 +00:00
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
sub.device->pixels_alloc(mem);
|
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_free(device_memory& mem)
|
|
|
|
{
|
2011-09-12 13:13:56 +00:00
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->pixels_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_copy_from(device_memory& mem, int y, int w, int h)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
int i = 0, sub_h = h/devices.size();
|
|
|
|
|
|
|
|
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->pixels_copy_from(mem, sy, w, sh);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2017-04-28 17:25:57 +00:00
|
|
|
void draw_pixels(
|
|
|
|
device_memory& rgba, int y,
|
|
|
|
int w, int h, int width, int height,
|
|
|
|
int dx, int dy, int dw, int dh,
|
|
|
|
bool transparent, const DeviceDrawParams &draw_params)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
device_ptr tmp = rgba.device_pointer;
|
|
|
|
int i = 0, sub_h = h/devices.size();
|
2011-09-12 13:13:56 +00:00
|
|
|
int sub_height = height/devices.size();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
int sy = y + i*sub_h;
|
|
|
|
int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
|
2011-09-12 13:13:56 +00:00
|
|
|
int sheight = (i == (int)devices.size() - 1)? height - sub_height*i: sub_height;
|
2012-01-04 18:06:32 +00:00
|
|
|
int sdy = dy + i*sub_height;
|
2011-04-27 11:58:34 +00:00
|
|
|
/* adjust math for w/width */
|
|
|
|
|
|
|
|
rgba.device_pointer = sub.ptr_map[tmp];
|
2017-04-28 17:25:57 +00:00
|
|
|
sub.device->draw_pixels(rgba, sy, w, sh, width, sheight, dx, sdy, dw, dh, transparent, draw_params);
|
2011-04-27 11:58:34 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
rgba.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
void map_tile(Device *sub_device, RenderTile& tile)
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device == sub_device) {
|
|
|
|
if(tile.buffer) tile.buffer = sub.ptr_map[tile.buffer];
|
|
|
|
if(tile.rng_state) tile.rng_state = sub.ptr_map[tile.rng_state];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int device_number(Device *sub_device)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device == sub_device)
|
|
|
|
return i;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-05-07 12:40:58 +00:00
|
|
|
void map_neighbor_tiles(Device *sub_device, RenderTile *tiles)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 9; i++) {
|
|
|
|
if(!tiles[i].buffers) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* If the tile was rendered on another device, copy its memory to
|
|
|
|
* to the current device now, for the duration of the denoising task.
|
|
|
|
* Note that this temporarily modifies the RenderBuffers and calls
|
|
|
|
* the device, so this function is not thread safe. */
|
|
|
|
if(tiles[i].buffers->device != sub_device) {
|
|
|
|
device_vector<float> &mem = tiles[i].buffers->buffer;
|
|
|
|
|
|
|
|
tiles[i].buffers->copy_from_device();
|
|
|
|
device_ptr original_ptr = mem.device_pointer;
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
sub_device->mem_alloc("Temporary memory for neighboring tile", mem, MEM_READ_WRITE);
|
|
|
|
sub_device->mem_copy_to(mem);
|
|
|
|
tiles[i].buffer = mem.device_pointer;
|
|
|
|
mem.device_pointer = original_ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void unmap_neighbor_tiles(Device * sub_device, RenderTile * tiles)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 9; i++) {
|
|
|
|
if(!tiles[i].buffers) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(tiles[i].buffers->device != sub_device) {
|
|
|
|
device_vector<float> &mem = tiles[i].buffers->buffer;
|
|
|
|
|
|
|
|
device_ptr original_ptr = mem.device_pointer;
|
|
|
|
mem.device_pointer = tiles[i].buffer;
|
|
|
|
|
|
|
|
/* Copy denoised tile to the host. */
|
|
|
|
if(i == 4) {
|
|
|
|
tiles[i].buffers->copy_from_device(sub_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t mem_size = mem.device_size;
|
|
|
|
sub_device->mem_free(mem);
|
|
|
|
mem.device_pointer = original_ptr;
|
|
|
|
mem.device_size = mem_size;
|
|
|
|
|
|
|
|
/* Copy denoised tile to the original device. */
|
|
|
|
if(i == 4) {
|
|
|
|
tiles[i].buffers->device->mem_copy_to(mem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-22 21:41:01 +00:00
|
|
|
int get_split_task_count(DeviceTask& task)
|
|
|
|
{
|
2014-08-05 16:50:50 +00:00
|
|
|
int total_tasks = 0;
|
|
|
|
list<DeviceTask> tasks;
|
|
|
|
task.split(tasks, devices.size());
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(!tasks.empty()) {
|
|
|
|
DeviceTask subtask = tasks.front();
|
|
|
|
tasks.pop_front();
|
|
|
|
|
|
|
|
total_tasks += sub.device->get_split_task_count(subtask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return total_tasks;
|
2014-07-22 21:41:01 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void task_add(DeviceTask& task)
|
|
|
|
{
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
list<DeviceTask> tasks;
|
2011-04-27 11:58:34 +00:00
|
|
|
task.split(tasks, devices.size());
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
if(!tasks.empty()) {
|
|
|
|
DeviceTask subtask = tasks.front();
|
|
|
|
tasks.pop_front();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
if(task.buffer) subtask.buffer = sub.ptr_map[task.buffer];
|
2013-08-30 23:49:38 +00:00
|
|
|
if(task.rgba_byte) subtask.rgba_byte = sub.ptr_map[task.rgba_byte];
|
|
|
|
if(task.rgba_half) subtask.rgba_half = sub.ptr_map[task.rgba_half];
|
2011-12-31 15:18:13 +00:00
|
|
|
if(task.shader_input) subtask.shader_input = sub.ptr_map[task.shader_input];
|
|
|
|
if(task.shader_output) subtask.shader_output = sub.ptr_map[task.shader_output];
|
2015-12-30 14:04:01 +00:00
|
|
|
if(task.shader_output_luma) subtask.shader_output_luma = sub.ptr_map[task.shader_output_luma];
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
sub.device->task_add(subtask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_wait()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->task_wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_cancel()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->task_cancel();
|
|
|
|
}
|
2016-09-23 10:43:23 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Stats sub_stats_;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
2012-11-05 08:04:57 +00:00
|
|
|
Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
|
2012-01-04 18:06:32 +00:00
|
|
|
{
|
2012-11-05 08:04:57 +00:00
|
|
|
return new MultiDevice(info, stats, background);
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|