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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEVICE_H__
|
|
|
|
#define __DEVICE_H__
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
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_memory.h"
|
|
|
|
#include "device/device_task.h"
|
|
|
|
|
|
|
|
#include "util/util_list.h"
|
|
|
|
#include "util/util_stats.h"
|
|
|
|
#include "util/util_string.h"
|
|
|
|
#include "util/util_thread.h"
|
2017-10-06 19:47:41 +00:00
|
|
|
#include "util/util_texture.h"
|
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_types.h"
|
|
|
|
#include "util/util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class Progress;
|
2012-09-04 13:29:07 +00:00
|
|
|
class RenderTile;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
/* Device Types */
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
enum DeviceType {
|
|
|
|
DEVICE_NONE,
|
|
|
|
DEVICE_CPU,
|
|
|
|
DEVICE_OPENCL,
|
|
|
|
DEVICE_CUDA,
|
|
|
|
DEVICE_NETWORK,
|
|
|
|
DEVICE_MULTI
|
|
|
|
};
|
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
class DeviceInfo {
|
|
|
|
public:
|
|
|
|
DeviceType type;
|
|
|
|
string description;
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 01:33:53 +00:00
|
|
|
string id; /* used for user preferences, should stay fixed with changing hardware config */
|
2012-01-04 18:06:32 +00:00
|
|
|
int num;
|
|
|
|
bool display_device;
|
2012-01-26 19:07:01 +00:00
|
|
|
bool advanced_shading;
|
2016-05-19 10:47:41 +00:00
|
|
|
bool has_bindless_textures; /* flag for GPU and Multi device */
|
2017-10-08 02:32:25 +00:00
|
|
|
bool has_volume_decoupled;
|
|
|
|
bool has_qbvh;
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
bool use_split_kernel; /* Denotes if the device is going to run cycles using split-kernel */
|
2012-01-04 18:06:32 +00:00
|
|
|
vector<DeviceInfo> multi_devices;
|
|
|
|
|
|
|
|
DeviceInfo()
|
|
|
|
{
|
|
|
|
type = DEVICE_CPU;
|
|
|
|
id = "CPU";
|
|
|
|
num = 0;
|
|
|
|
display_device = false;
|
2012-01-26 19:07:01 +00:00
|
|
|
advanced_shading = true;
|
2016-05-19 10:47:41 +00:00
|
|
|
has_bindless_textures = false;
|
2017-10-08 02:32:25 +00:00
|
|
|
has_volume_decoupled = false;
|
|
|
|
has_qbvh = false;
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
use_split_kernel = false;
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 01:33:53 +00:00
|
|
|
|
|
|
|
bool operator==(const DeviceInfo &info) {
|
|
|
|
/* Multiple Devices with the same ID would be very bad. */
|
|
|
|
assert(id != info.id || (type == info.type && num == info.num && description == info.description));
|
|
|
|
return id == info.id;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
2015-05-09 14:05:49 +00:00
|
|
|
class DeviceRequestedFeatures {
|
|
|
|
public:
|
|
|
|
/* Use experimental feature set. */
|
|
|
|
bool experimental;
|
|
|
|
|
2015-05-09 14:28:00 +00:00
|
|
|
/* Maximum number of closures in shader trees. */
|
|
|
|
int max_closure;
|
|
|
|
|
|
|
|
/* Selective nodes compilation. */
|
|
|
|
|
|
|
|
/* Identifier of a node group up to which all the nodes needs to be
|
|
|
|
* compiled in. Nodes from higher group indices will be ignores.
|
|
|
|
*/
|
|
|
|
int max_nodes_group;
|
|
|
|
|
|
|
|
/* Features bitfield indicating which features from the requested group
|
|
|
|
* will be compiled in. Nodes which corresponds to features which are not
|
|
|
|
* in this bitfield will be ignored even if they're in the requested group.
|
|
|
|
*/
|
|
|
|
int nodes_features;
|
|
|
|
|
2015-06-05 17:50:22 +00:00
|
|
|
/* BVH/sampling kernel features. */
|
|
|
|
bool use_hair;
|
|
|
|
bool use_object_motion;
|
|
|
|
bool use_camera_motion;
|
|
|
|
|
2015-07-18 13:34:32 +00:00
|
|
|
/* Denotes whether baking functionality is needed. */
|
|
|
|
bool use_baking;
|
|
|
|
|
2015-11-21 17:31:58 +00:00
|
|
|
/* Use subsurface scattering materials. */
|
|
|
|
bool use_subsurface;
|
|
|
|
|
2016-05-06 21:11:41 +00:00
|
|
|
/* Use volume materials. */
|
|
|
|
bool use_volume;
|
|
|
|
|
2015-11-22 08:54:51 +00:00
|
|
|
/* Use branched integrator. */
|
|
|
|
bool use_integrator_branched;
|
|
|
|
|
2016-08-15 13:08:38 +00:00
|
|
|
/* Use OpenSubdiv patch evaluation */
|
|
|
|
bool use_patch_evaluation;
|
2016-12-09 15:28:04 +00:00
|
|
|
|
|
|
|
/* Use Transparent shadows */
|
|
|
|
bool use_transparent;
|
2016-08-15 13:08:38 +00:00
|
|
|
|
2017-03-21 12:55:27 +00:00
|
|
|
/* Use various shadow tricks, such as shadow catcher. */
|
|
|
|
bool use_shadow_tricks;
|
|
|
|
|
2017-04-21 10:56:54 +00:00
|
|
|
/* Per-uber shader usage flags. */
|
|
|
|
bool use_principled;
|
|
|
|
|
2017-06-09 07:11:54 +00:00
|
|
|
/* Denoising features. */
|
|
|
|
bool use_denoising;
|
|
|
|
|
2015-05-09 14:05:49 +00:00
|
|
|
DeviceRequestedFeatures()
|
|
|
|
{
|
2015-05-09 14:28:00 +00:00
|
|
|
/* TODO(sergey): Find more meaningful defaults. */
|
2015-05-09 14:05:49 +00:00
|
|
|
experimental = false;
|
2015-05-09 14:28:00 +00:00
|
|
|
max_closure = 0;
|
|
|
|
max_nodes_group = 0;
|
|
|
|
nodes_features = 0;
|
2015-06-05 17:50:22 +00:00
|
|
|
use_hair = false;
|
|
|
|
use_object_motion = false;
|
|
|
|
use_camera_motion = false;
|
2015-07-18 13:34:32 +00:00
|
|
|
use_baking = false;
|
2015-11-21 17:31:58 +00:00
|
|
|
use_subsurface = false;
|
2016-05-06 21:11:41 +00:00
|
|
|
use_volume = false;
|
2015-11-22 08:54:51 +00:00
|
|
|
use_integrator_branched = false;
|
2016-08-15 13:08:38 +00:00
|
|
|
use_patch_evaluation = false;
|
2016-12-09 15:28:04 +00:00
|
|
|
use_transparent = false;
|
2017-03-21 12:55:27 +00:00
|
|
|
use_shadow_tricks = false;
|
2017-04-21 10:56:54 +00:00
|
|
|
use_principled = false;
|
2017-06-09 07:11:54 +00:00
|
|
|
use_denoising = false;
|
2015-05-09 14:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool modified(const DeviceRequestedFeatures& requested_features)
|
|
|
|
{
|
2015-05-09 14:28:00 +00:00
|
|
|
return !(experimental == requested_features.experimental &&
|
|
|
|
max_closure == requested_features.max_closure &&
|
|
|
|
max_nodes_group == requested_features.max_nodes_group &&
|
2015-07-18 13:34:32 +00:00
|
|
|
nodes_features == requested_features.nodes_features &&
|
|
|
|
use_hair == requested_features.use_hair &&
|
|
|
|
use_object_motion == requested_features.use_object_motion &&
|
|
|
|
use_camera_motion == requested_features.use_camera_motion &&
|
2015-11-21 17:31:58 +00:00
|
|
|
use_baking == requested_features.use_baking &&
|
2015-11-22 08:54:51 +00:00
|
|
|
use_subsurface == requested_features.use_subsurface &&
|
2016-05-06 21:11:41 +00:00
|
|
|
use_volume == requested_features.use_volume &&
|
2016-08-15 13:08:38 +00:00
|
|
|
use_integrator_branched == requested_features.use_integrator_branched &&
|
2016-12-09 15:28:04 +00:00
|
|
|
use_patch_evaluation == requested_features.use_patch_evaluation &&
|
2017-03-21 12:55:27 +00:00
|
|
|
use_transparent == requested_features.use_transparent &&
|
2017-04-21 10:56:54 +00:00
|
|
|
use_shadow_tricks == requested_features.use_shadow_tricks &&
|
2017-06-09 07:11:54 +00:00
|
|
|
use_principled == requested_features.use_principled &&
|
|
|
|
use_denoising == requested_features.use_denoising);
|
2015-05-09 14:05:49 +00:00
|
|
|
}
|
2015-07-18 14:00:07 +00:00
|
|
|
|
2015-11-21 16:42:31 +00:00
|
|
|
/* Convert the requested features structure to a build options,
|
|
|
|
* which could then be passed to compilers.
|
|
|
|
*/
|
|
|
|
string get_build_options(void) const
|
|
|
|
{
|
|
|
|
string build_options = "";
|
|
|
|
if(experimental) {
|
|
|
|
build_options += "-D__KERNEL_EXPERIMENTAL__ ";
|
|
|
|
}
|
|
|
|
build_options += "-D__NODES_MAX_GROUP__=" +
|
|
|
|
string_printf("%d", max_nodes_group);
|
|
|
|
build_options += " -D__NODES_FEATURES__=" +
|
|
|
|
string_printf("%d", nodes_features);
|
|
|
|
build_options += string_printf(" -D__MAX_CLOSURE__=%d", max_closure);
|
|
|
|
if(!use_hair) {
|
|
|
|
build_options += " -D__NO_HAIR__";
|
|
|
|
}
|
|
|
|
if(!use_object_motion) {
|
|
|
|
build_options += " -D__NO_OBJECT_MOTION__";
|
|
|
|
}
|
|
|
|
if(!use_camera_motion) {
|
|
|
|
build_options += " -D__NO_CAMERA_MOTION__";
|
|
|
|
}
|
|
|
|
if(!use_baking) {
|
|
|
|
build_options += " -D__NO_BAKING__";
|
|
|
|
}
|
2016-05-06 21:11:41 +00:00
|
|
|
if(!use_volume) {
|
|
|
|
build_options += " -D__NO_VOLUME__";
|
|
|
|
}
|
2015-11-21 17:31:58 +00:00
|
|
|
if(!use_subsurface) {
|
|
|
|
build_options += " -D__NO_SUBSURFACE__";
|
|
|
|
}
|
2015-11-22 08:54:51 +00:00
|
|
|
if(!use_integrator_branched) {
|
|
|
|
build_options += " -D__NO_BRANCHED_PATH__";
|
|
|
|
}
|
2016-08-15 13:08:38 +00:00
|
|
|
if(!use_patch_evaluation) {
|
|
|
|
build_options += " -D__NO_PATCH_EVAL__";
|
|
|
|
}
|
2017-03-08 14:42:26 +00:00
|
|
|
if(!use_transparent && !use_volume) {
|
2016-12-09 15:28:04 +00:00
|
|
|
build_options += " -D__NO_TRANSPARENT__";
|
|
|
|
}
|
2017-03-21 12:55:27 +00:00
|
|
|
if(!use_shadow_tricks) {
|
|
|
|
build_options += " -D__NO_SHADOW_TRICKS__";
|
|
|
|
}
|
2017-04-21 10:56:54 +00:00
|
|
|
if(!use_principled) {
|
|
|
|
build_options += " -D__NO_PRINCIPLED__";
|
|
|
|
}
|
2017-06-09 07:11:54 +00:00
|
|
|
if(!use_denoising) {
|
|
|
|
build_options += " -D__NO_DENOISING__";
|
|
|
|
}
|
2015-11-21 16:42:31 +00:00
|
|
|
return build_options;
|
|
|
|
}
|
2015-05-09 14:05:49 +00:00
|
|
|
};
|
|
|
|
|
2015-07-18 14:00:07 +00:00
|
|
|
std::ostream& operator <<(std::ostream &os,
|
|
|
|
const DeviceRequestedFeatures& requested_features);
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Device */
|
|
|
|
|
2014-03-26 08:57:30 +00:00
|
|
|
struct DeviceDrawParams {
|
2015-03-29 20:12:22 +00:00
|
|
|
function<void(void)> bind_display_space_shader_cb;
|
|
|
|
function<void(void)> unbind_display_space_shader_cb;
|
2014-03-26 08:57:30 +00:00
|
|
|
};
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
class Device {
|
2017-05-07 12:40:58 +00:00
|
|
|
friend class device_sub_ptr;
|
2011-04-27 11:58:34 +00:00
|
|
|
protected:
|
2015-05-11 14:28:41 +00:00
|
|
|
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
bool background;
|
2011-11-22 20:49:33 +00:00
|
|
|
string error_msg;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-05-11 14:28:41 +00:00
|
|
|
/* used for real time display */
|
|
|
|
unsigned int vertex_buffer;
|
|
|
|
|
2017-05-07 12:40:58 +00:00
|
|
|
virtual device_ptr mem_alloc_sub_ptr(device_memory& /*mem*/, int /*offset*/, int /*size*/, MemoryType /*type*/)
|
|
|
|
{
|
|
|
|
/* Only required for devices that implement denoising. */
|
|
|
|
assert(false);
|
|
|
|
return (device_ptr) 0;
|
|
|
|
}
|
|
|
|
virtual void mem_free_sub_ptr(device_ptr /*ptr*/) {};
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
public:
|
2015-05-11 14:28:41 +00:00
|
|
|
virtual ~Device();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* info */
|
2012-01-26 19:07:01 +00:00
|
|
|
DeviceInfo info;
|
2012-01-04 18:06:32 +00:00
|
|
|
virtual const string& error_message() { return error_msg; }
|
2012-12-23 12:53:58 +00:00
|
|
|
bool have_error() { return !error_message().empty(); }
|
2017-03-11 12:03:17 +00:00
|
|
|
virtual void set_error(const string& error)
|
|
|
|
{
|
|
|
|
if(!have_error()) {
|
|
|
|
error_msg = error;
|
|
|
|
}
|
|
|
|
fprintf(stderr, "%s\n", error.c_str());
|
|
|
|
fflush(stderr);
|
|
|
|
}
|
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 { return false; }
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-11-05 08:04:57 +00:00
|
|
|
/* statistics */
|
|
|
|
Stats &stats;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* regular memory */
|
2016-12-14 01:45:09 +00:00
|
|
|
virtual void mem_alloc(const char *name, device_memory& mem, MemoryType type) = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
virtual void mem_copy_to(device_memory& mem) = 0;
|
|
|
|
virtual void mem_copy_from(device_memory& mem,
|
2012-01-09 16:58:01 +00:00
|
|
|
int y, int w, int h, int elem) = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
virtual void mem_zero(device_memory& mem) = 0;
|
|
|
|
virtual void mem_free(device_memory& mem) = 0;
|
|
|
|
|
2017-05-07 12:40:58 +00:00
|
|
|
virtual int mem_address_alignment() { return 16; }
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* constant memory */
|
|
|
|
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
|
|
|
|
|
|
|
|
/* texture memory */
|
2015-03-27 10:47:55 +00:00
|
|
|
virtual void tex_alloc(const char * /*name*/,
|
|
|
|
device_memory& /*mem*/,
|
|
|
|
InterpolationType interpolation = INTERPOLATION_NONE,
|
2015-07-28 11:51:10 +00:00
|
|
|
ExtensionType extension = EXTENSION_REPEAT)
|
2015-03-27 10:47:55 +00:00
|
|
|
{
|
|
|
|
(void)interpolation; /* Ignored. */
|
2015-07-28 11:51:10 +00:00
|
|
|
(void)extension; /* Ignored. */
|
2015-03-27 10:47:55 +00:00
|
|
|
};
|
2016-05-19 10:47:41 +00:00
|
|
|
|
2015-03-27 10:47:55 +00:00
|
|
|
virtual void tex_free(device_memory& /*mem*/) {};
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
/* pixel memory */
|
|
|
|
virtual void pixels_alloc(device_memory& mem);
|
|
|
|
virtual void pixels_copy_from(device_memory& mem, int y, int w, int h);
|
|
|
|
virtual void pixels_free(device_memory& mem);
|
|
|
|
|
|
|
|
/* open shading language, only for CPU device */
|
|
|
|
virtual void *osl_memory() { return NULL; }
|
|
|
|
|
2011-09-02 00:10:03 +00:00
|
|
|
/* load/compile kernels, must be called before adding tasks */
|
2015-05-09 14:05:49 +00:00
|
|
|
virtual bool load_kernels(
|
|
|
|
const DeviceRequestedFeatures& /*requested_features*/)
|
|
|
|
{ return true; }
|
2011-09-02 00:10:03 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* tasks */
|
2014-07-22 21:41:01 +00:00
|
|
|
virtual int get_split_task_count(DeviceTask& task) = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
virtual void task_add(DeviceTask& task) = 0;
|
|
|
|
virtual void task_wait() = 0;
|
|
|
|
virtual void task_cancel() = 0;
|
|
|
|
|
|
|
|
/* opengl drawing */
|
|
|
|
virtual void draw_pixels(device_memory& mem, int y, int w, int h,
|
2015-05-11 14:40:38 +00:00
|
|
|
int dx, int dy, int width, int height, bool transparent,
|
2014-03-26 08:57:30 +00:00
|
|
|
const DeviceDrawParams &draw_params);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
#ifdef WITH_NETWORK
|
|
|
|
/* networking */
|
|
|
|
void server_run();
|
|
|
|
#endif
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
/* multi device */
|
2015-03-27 10:47:55 +00:00
|
|
|
virtual void map_tile(Device * /*sub_device*/, RenderTile& /*tile*/) {}
|
|
|
|
virtual int device_number(Device * /*sub_device*/) { return 0; }
|
2017-05-07 12:40:58 +00:00
|
|
|
virtual void map_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/) {}
|
|
|
|
virtual void unmap_neighbor_tiles(Device * /*sub_device*/, RenderTile * /*tiles*/) {}
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* static */
|
2012-11-07 21:00:49 +00:00
|
|
|
static Device *create(DeviceInfo& info, Stats &stats, bool background = true);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
static DeviceType type_from_string(const char *name);
|
|
|
|
static string string_from_type(DeviceType type);
|
2012-01-04 18:06:32 +00:00
|
|
|
static vector<DeviceType>& available_types();
|
|
|
|
static vector<DeviceInfo>& available_devices();
|
2015-01-06 09:13:21 +00:00
|
|
|
static string device_capabilities();
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 01:33:53 +00:00
|
|
|
static DeviceInfo get_multi_device(vector<DeviceInfo> subdevices);
|
2016-01-12 11:00:48 +00:00
|
|
|
|
|
|
|
/* Tag devices lists for update. */
|
|
|
|
static void tag_update();
|
|
|
|
|
2016-02-06 22:40:41 +00:00
|
|
|
static void free_memory();
|
2016-01-12 11:00:48 +00:00
|
|
|
private:
|
|
|
|
/* Indicted whether device types and devices lists were initialized. */
|
|
|
|
static bool need_types_update, need_devices_update;
|
2017-10-11 07:48:19 +00:00
|
|
|
static thread_mutex device_mutex;
|
2016-02-06 22:40:41 +00:00
|
|
|
static vector<DeviceType> types;
|
|
|
|
static vector<DeviceInfo> devices;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __DEVICE_H__ */
|
|
|
|
|